• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tensorchord / openmodelz / 6180409240

14 Sep 2023 03:02AM UTC coverage: 26.069% (-3.9%) from 29.927%
6180409240

push

github

web-flow
feat: Support BYOC (#171)

Signed-off-by: xieydd <xieydd@gmail.com>

443 of 443 new or added lines in 14 files covered. (100.0%)

939 of 3602 relevant lines covered (26.07%)

1.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/agent/pkg/server/handler_other_proxy.go
1
package server
2

3
import (
4
        "fmt"
5
        "net"
6
        "net/http"
7
        "net/http/httputil"
8
        "net/url"
9
        "path"
10
        "time"
11

12
        "github.com/gin-gonic/gin"
13
        "github.com/tensorchord/openmodelz/agent/pkg/consts"
14
)
15

16
// @Summary     Reverse proxy to the backend other.
17
// @Description Reverse proxy to the backend other.
18
// @Tags        inference
19
// @Accept      */*
20
// @Produce     json
21
// @Param       id path string true "Deployment ID"
22
// @Router      /other/{id} [get]
23
// @Router      /other/{id} [post]
24
// @Success     201
25
func (s *Server) proxyOther(c *gin.Context) error {
×
26
        remote, err := url.Parse(fmt.Sprintf("http://0.0.0.0:%d", s.config.Server.ServerPort))
×
27
        if err != nil {
×
28
                return err
×
29
        }
×
30
        proxy := httputil.NewSingleHostReverseProxy(remote)
×
31
        proxy.Transport = &http.Transport{
×
32
                Proxy: http.ProxyFromEnvironment,
×
33
                DialContext: (&net.Dialer{
×
34
                        Timeout:   s.config.ModelZCloud.UpstreamTimeout,
×
35
                        KeepAlive: s.config.ModelZCloud.UpstreamTimeout,
×
36
                        DualStack: true,
×
37
                }).DialContext,
×
38
                MaxIdleConns:          s.config.ModelZCloud.MaxIdleConnections,
×
39
                MaxIdleConnsPerHost:   s.config.ModelZCloud.MaxIdleConnectionsPerHost,
×
40
                IdleConnTimeout:       90 * time.Second,
×
41
                TLSHandshakeTimeout:   10 * time.Second,
×
42
                ExpectContinueTimeout: 1 * time.Second,
×
43
        }
×
44

×
45
        uid, deployment, err := s.proxyAuth(c)
×
46
        if err != nil {
×
47
                return err
×
48
        }
×
49

50
        proxy.Director = func(req *http.Request) {
×
51
                req.Header = c.Request.Header
×
52
                req.Host = remote.Host
×
53
                req.URL.Scheme = remote.Scheme
×
54
                req.URL.Host = remote.Host
×
55
                req.URL.Path = path.Join(
×
56
                        "/", "inference", fmt.Sprintf("%s.%s", deployment, consts.DefaultPrefix+uid), c.Param("proxyPath"))
×
57
        }
×
58

59
        proxy.ServeHTTP(c.Writer, c.Request)
×
60
        return nil
×
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc