test

package
v0.0.0-...-76c172a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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

func (*Provider) Shutdown

func (t *Provider) Shutdown(_ bool) error

func (*Provider) StartClient

func (t *Provider) StartClient(cluster *cluster.Cluster) error

func (*Provider) StartMember

func (t *Provider) StartMember(c *cluster.Cluster) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL