Documentation ¶
Index ¶
- type AgentServiceStatus
- type InMemAgent
- func (m *InMemAgent) DeregisterService(id string)
- func (m *InMemAgent) ForceUpdate()
- func (m *InMemAgent) GetStatusHealth() []AgentServiceStatus
- func (m *InMemAgent) RefreshServiceTTL(id string)
- func (m *InMemAgent) RegisterService(registration AgentServiceStatus)
- func (m *InMemAgent) SubscribeStatusUpdate(handler func())
- type Provider
- type ProviderConfig
- type ProviderOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentServiceStatus ¶
type AgentServiceStatus struct { ID string TTL time.Time // last alive time Host string Port int Kinds []string }
func NewAgentServiceStatus ¶
func NewAgentServiceStatus(id string, host string, port int, kinds []string) AgentServiceStatus
NewAgentServiceStatus creates a new AgentServiceStatus.
func (AgentServiceStatus) Alive ¶
func (a AgentServiceStatus) Alive() bool
type InMemAgent ¶
type InMemAgent struct {
// contains filtered or unexported fields
}
func NewInMemAgent ¶
func NewInMemAgent() *InMemAgent
func (*InMemAgent) DeregisterService ¶
func (m *InMemAgent) DeregisterService(id string)
DeregisterService removes a service from the agent.
func (*InMemAgent) ForceUpdate ¶
func (m *InMemAgent) ForceUpdate()
ForceUpdate is used to trigger a status update event.
func (*InMemAgent) GetStatusHealth ¶
func (m *InMemAgent) GetStatusHealth() []AgentServiceStatus
GetStatusHealth returns the health of the service.
func (*InMemAgent) RefreshServiceTTL ¶
func (m *InMemAgent) RefreshServiceTTL(id string)
RefreshServiceTTL updates the TTL of all services.
func (*InMemAgent) RegisterService ¶
func (m *InMemAgent) RegisterService(registration AgentServiceStatus)
RegisterService registers a AgentServiceStatus with the agent.
func (*InMemAgent) SubscribeStatusUpdate ¶
func (m *InMemAgent) SubscribeStatusUpdate(handler func())
SubscribeStatusUpdate registers a handler that will be called when the service map changes.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func NewTestProvider ¶
func NewTestProvider(agent *InMemAgent, options ...ProviderOption) *Provider
type ProviderConfig ¶
type ProviderConfig struct { // ServiceTtl is the time to live for services. Default: 3s ServiceTtl time.Duration // RefreshTtl is the time between refreshes of the service ttl. Default: 1s RefreshTtl time.Duration // DeregisterCritical is the time after which a service is deregistered if it is not refreshed. Default: 10s DeregisterCritical time.Duration }
type ProviderOption ¶
type ProviderOption func(config *ProviderConfig)
func WithTestProviderDeregisterCritical ¶
func WithTestProviderDeregisterCritical(deregisterCritical time.Duration) ProviderOption
WithTestProviderDeregisterCritical sets the deregister critical. Default: 10s
func WithTestProviderRefreshTtl ¶
func WithTestProviderRefreshTtl(refreshTtl time.Duration) ProviderOption
WithTestProviderRefreshTtl sets the refresh ttl. Default: 1s
func WithTestProviderServiceTtl ¶
func WithTestProviderServiceTtl(serviceTtl time.Duration) ProviderOption
WithTestProviderServiceTtl sets the service ttl. Default: 3s
Click to show internal directories.
Click to hide internal directories.