caller.go ×17

Frontier kind: Joint frontier

unlabeled · c_58659151e481

1 test · 42 LOC · 1 file · introduces 1 test · 42 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges42 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
17 ranges42 lines · 1 file · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 42 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/versioninfo/caller.go 42 introduced LOC · 17 ranges

Open complete file

21 }
22
23 > func (c Caller) Call(r *VersionCheckRequest) (*VersionCheckResponse, error) { caller.go
24 > err := validateRequest(r)
25 > if err != nil {
26 return nil, err
27 }
28 > u := c.getUrl(r) caller.go
29 > tr := &http.Transport{
30 > DisableKeepAlives: true,
31 > MaxIdleConnsPerHost: -1,
32 > }
33 > if c.Scheme == "https" {
34 tr.TLSClientConfig = &tls.Config{}
35 }
36 > client := &http.Client{Transport: tr} caller.go
37 > reqBody, err := json.Marshal(r)
38 > if err != nil {
39 return nil, err
40 }
41 > req, err := http.NewRequest("POST", u.String(), bytes.NewReader(reqBody)) caller.go
42 > if err != nil {
43 return nil, err
44 }
45 > req.Header.Set("Content-Type", "application/json") caller.go
46 > resp, err := client.Do(req)
47 > if err != nil {
48 return nil, err
49 }
50 > if resp.StatusCode != 200 { caller.go
51 return nil, fmt.Errorf("bad response code %v", resp.StatusCode)
52 }
53 > defer resp.Body.Close() caller.go
54 > body, err := io.ReadAll(resp.Body)
55 > if err != nil {
56 return nil, err
57 }
58 > versionCheckResponse := &VersionCheckResponse{} caller.go
59 > if err := json.Unmarshal(body, versionCheckResponse); err != nil {
60 return nil, err
61 }
62 > if err := validateResponse(versionCheckResponse); err != nil { caller.go
63 return nil, err
64 }
65 > return versionCheckResponse, nil caller.go
66 }
67
68 > func validateResponse(r *VersionCheckResponse) error { caller.go
69 > if len(r.Products) == 0 {
70 return errors.New("invalid response: missing product list")
71 }
72 > firstProduct := r.Products[0] caller.go
73 > if firstProduct.Product == "" || firstProduct.Current.Version == "" || firstProduct.Recommended.Version == "" {
74 return errors.New("invalid response: missing product name, current or recommended version")
75 }
76 > return nil caller.go
77 }
78 > func validateRequest(r *VersionCheckRequest) error { caller.go
79 > if r.Product == "" || r.Version == "" || r.ClusterID == "" || r.DB == "" || r.OS == "" || r.Arch == "" || r.Timestamp == 0 {
80 return errors.New("invalid request: missing required fields")
81 }
82 > for _, info := range r.SDKInfo { caller.go
83 > if info.Name == "" || info.Version == "" {
84 return errors.New("invalid request: missing required fields")
85 }
86 }
87 > return nil caller.go
88 }
89
90 > func (c Caller) getUrl(r *VersionCheckRequest) *url.URL { caller.go
91 > var u url.URL
92 > u.Scheme = c.Scheme
93 > u.Host = c.Host
94 > u.Path = "check"
95 > return &u
96 > }