Struct: endpoint-discovery.Endpoint

import "../ibm-cos-sdk-go-v2/service/internal/endpoint-discovery"

Overview

Endpoint represents an endpoint used in endpoint discovery.

Implemented Interfaces

types.AnalyticsFilter, v4.HTTPPresigner, s3.HTTPPresignerV4, types.MetricsFilter, s3.PresignPost, arn.S3ObjectLambdaARN, types.SelectObjectContentEventStream

Structure Field Summary collapse

Method Summary collapse

Structure Field Details

Addresses WeightedAddresses

Key string

Method Details

func (e *Endpoint) Add(addr WeightedAddress)

Add will add a given WeightedAddress to the address list of Endpoint.



29
30
31
// File 'service/internal/endpoint-discovery/endpoint.go', line 29

func (e *Endpoint) Add(addr WeightedAddress) { e.Addresses = append(e.Addresses, addr) }

func (e *Endpoint) GetValidAddress() (WeightedAddress, bool)

GetValidAddress will return a non-expired weight endpoint



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// File 'service/internal/endpoint-discovery/endpoint.go', line 48

func (e *Endpoint) GetValidAddress() (WeightedAddress, bool) { for i := 0; i < len(e.Addresses); i++ { we := e.Addresses[i] if we.HasExpired() { continue } we.URL = cloneURL(we.URL) return we, true } return WeightedAddress{}, false }

func (e *Endpoint) Len() int

Len returns the number of valid endpoints where valid means the endpoint has not expired.



35
36
37
38
39
40
41
42
43
44
45
// File 'service/internal/endpoint-discovery/endpoint.go', line 35

func (e *Endpoint) Len() int { validEndpoints := 0 for _, endpoint := range e.Addresses { if endpoint.HasExpired() { continue } validEndpoints++ } return validEndpoints }

func (e *Endpoint) Prune() bool

Prune will prune the expired addresses from the endpoint by allocating a new []WeightAddress. This is not concurrent safe, and should be called from a single owning thread.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// File 'service/internal/endpoint-discovery/endpoint.go', line 66

func (e *Endpoint) Prune() bool { validLen := e.Len() if validLen == len(e.Addresses) { return false } wa := make([]WeightedAddress, 0, validLen) for i := range e.Addresses { if e.Addresses[i].HasExpired() { continue } wa = append(wa, e.Addresses[i]) } e.Addresses = wa return true }