MCPcopy
hub / github.com/segmentio/kafka-go / ecsAvailabilityZone

Function ecsAvailabilityZone

example_groupbalancer_test.go:76–97  ·  view source on GitHub ↗

ecsAvailabilityZone queries the task endpoint for the metadata URI that ECS injects into the ECS_CONTAINER_METADATA_URI variable in order to retrieve the availability zone where the task is running.

()

Source from the content-addressed store, hash-verified

74// injects into the ECS_CONTAINER_METADATA_URI variable in order to retrieve
75// the availability zone where the task is running.
76func ecsAvailabilityZone() string {
77 client := http.Client{
78 Timeout: time.Second,
79 Transport: &http.Transport{
80 DisableCompression: true,
81 DisableKeepAlives: true,
82 },
83 }
84 r, err := client.Get(os.Getenv(ecsContainerMetadataURI) + "/task")
85 if err != nil {
86 return ""
87 }
88 defer r.Body.Close()
89
90 var md struct {
91 AvailabilityZone string
92 }
93 if err := json.NewDecoder(r.Body).Decode(&md); err != nil {
94 return ""
95 }
96 return md.AvailabilityZone
97}
98
99// ec2AvailabilityZone queries the metadata endpoint to discover the
100// availability zone where this code is running. we avoid calling this function

Callers 1

findRackFunction · 0.85

Calls 2

GetMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected