Documentation
¶
Index ¶
- Constants
- Variables
- type Callback
- type Client
- type HealthStatus
- type Instance
- type InstanceMatcher
- func InstanceIsHealthy() InstanceMatcher
- func InstanceWithHealth(status HealthStatus) InstanceMatcher
- func InstanceWithMetaKV(key, value string) InstanceMatcher
- func InstanceWithTag(tag string, caseInsensitive bool) InstanceMatcher
- func InstanceWithTagKV(key, value string, caseInsensitive bool) InstanceMatcher
- func InstanceWithVersion(verPattern string) InstanceMatcher
- type Instancer
- type Service
- type ServiceCache
- type ServiceRegistrar
- type ServiceRegistration
- type ServiceRegistrationCustomizer
- type ServiceRegistrationCustomizerFunc
Constants ¶
const ( TagInstanceUUID = `instanceUuid` TagContextPath = `contextPath` TagComponentAttributes = `componentAttributes` TagServiceName = `name` TagBuildVersion = `version` TagBuildNumber = `buildNumber` TagBuildDateTime = `buildDateTime` TagSecure = `secure` ComponentAttributeDelimiter = `~` ComponentAttributeKeyValueSeparator = `:` )
const ( InstanceMetaKeyVersion = `version` InstanceMetaKeyContextPath = `context` InstanceMetaKeySMCR = `SMCR` )
const (
FxGroup = "discovery"
)
Variables ¶
var (
ErrInstancerStopped = fmt.Errorf("instancer is already stopped")
)
Functions ¶
This section is empty.
Types ¶
type HealthStatus ¶
type HealthStatus int
HealthStatus maintenance > critical > warning > passing
const ( HealthAny HealthStatus = iota HealthPassing HealthWarning HealthCritical HealthMaintenance )
type InstanceMatcher ¶
type InstanceMatcher matcher.ChainableMatcher
InstanceMatcher is a matcher.Matcher that takes Instance or *Instance
func InstanceIsHealthy ¶
func InstanceIsHealthy() InstanceMatcher
InstanceIsHealthy returns an InstanceMatcher that matches healthy instances
func InstanceWithHealth ¶
func InstanceWithHealth(status HealthStatus) InstanceMatcher
func InstanceWithMetaKV ¶
func InstanceWithMetaKV(key, value string) InstanceMatcher
func InstanceWithTag ¶
func InstanceWithTag(tag string, caseInsensitive bool) InstanceMatcher
func InstanceWithTagKV ¶
func InstanceWithTagKV(key, value string, caseInsensitive bool) InstanceMatcher
func InstanceWithVersion ¶
func InstanceWithVersion(verPattern string) InstanceMatcher
type Service ¶
func (*Service) InstanceCount ¶
func (s *Service) InstanceCount(selector InstanceMatcher) (ret int)
func (*Service) Instances ¶
func (s *Service) Instances(selector InstanceMatcher) (ret []*Instance)
type ServiceCache ¶
type ServiceCache interface { // Get returns service with given service name. return nil if not exist Get(name string) *Service // Set stores given service with name, returns non-nil if the service is already exists Set(name string, svc *Service) *Service // SetWithTTL stores given service with name and TTL, returns non-nil if the service is already exists // if ttl is zero or negative value, it's equivalent to Set SetWithTTL(name string, svc *Service, ttl time.Duration) *Service Has(name string) bool Entries() map[string]*Service }
ServiceCache is not goroutine-safe unless the detail implementation says so
type ServiceRegistrar ¶ added in v0.14.0
type ServiceRegistrar interface { Register(ctx context.Context, registration ServiceRegistration) error Deregister(ctx context.Context, registration ServiceRegistration) error }
ServiceRegistrar is the interface to interact with external service registration system.
type ServiceRegistration ¶ added in v0.14.0
type ServiceRegistration interface { ID() string Name() string Address() string Port() int Tags() []string Meta() map[string]any SetID(id string) SetName(name string) SetAddress(addr string) SetPort(port int) AddTags(tags ...string) RemoveTags(tags ...string) SetMeta(key string, value any) }
ServiceRegistration is the data to be registered with any external service registration system. It contains information about current running service instance. The implementation depends on which service discovery tech-stack is used. e.g. Consul would be *consulsd.ServiceRegistration
type ServiceRegistrationCustomizer ¶ added in v0.14.0
type ServiceRegistrationCustomizer interface {
Customize(ctx context.Context, reg ServiceRegistration)
}
ServiceRegistrationCustomizer customize given ServiceRegistration during bootstrap. Any ServiceRegistrationCustomizer provided with fx group defined as FxGroup will be applied automatically.
func NewBuildInfoCustomizer ¶ added in v0.14.0
func NewBuildInfoCustomizer() ServiceRegistrationCustomizer
NewBuildInfoCustomizer returns a ServiceRegistrationCustomizer that extract service's build information and put it in tags and metadata
func NewPropertiesBasedCustomizer ¶ added in v0.14.0
func NewPropertiesBasedCustomizer(appCtx *bootstrap.ApplicationContext, propertyPaths map[string]string) ServiceRegistrationCustomizer
NewPropertiesBasedCustomizer returns a ServiceRegistrationCustomizer that populate tags and metadata based on service's loaded properties and the given "propertyPaths". "propertyPaths" is a map that contains metadata key as "key" and its corresponding property path.
type ServiceRegistrationCustomizerFunc ¶ added in v0.14.0
type ServiceRegistrationCustomizerFunc func(ctx context.Context, reg ServiceRegistration)
ServiceRegistrationCustomizerFunc is the func that implements ServiceRegistrationCustomizer
func (ServiceRegistrationCustomizerFunc) Customize ¶ added in v0.14.0
func (fn ServiceRegistrationCustomizerFunc) Customize(ctx context.Context, reg ServiceRegistration)