Documentation ¶
Overview ¶
Deprecated: will be moved into another package.
Index ¶
- Variables
- type Address
- type Infrastructure
- func (i *Infrastructure) AddServiceServer(serviceName string, addr Address) error
- func (i *Infrastructure) MergeService(name string, s Service)
- func (i *Infrastructure) RegisterService(name string, s Service) error
- func (i *Infrastructure) RegisterServiceBatch(m map[string]Service) error
- func (i *Infrastructure) RegisterServiceBatchIgnore(m map[string]Service)
- type Service
- type ServiceType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServiceExists occurs when you trying to register a service that already exists ErrServiceExists = errors.New("service exists") )
var ErrServiceNotExists = errors.New("service is not exists")
ErrServiceNotExists occurs when you trying to add a server to service that not exists
var ( // ErrServiceTypeNotFound occurs when unknown service type // passed in GetTypeByString ErrServiceTypeNotFound = errors.New("service type not found") )
Functions ¶
This section is empty.
Types ¶
type Infrastructure ¶
type Infrastructure struct { Services map[string]*Service `json:"services"` UpdateTimestamp int64 `json:"update_timestamp"` CurrentTimestamp int64 `json:"current_timestamp"` Lock *sync.RWMutex `json:"-"` }
Infrastructure handles lists of services and current timestamp
func (*Infrastructure) AddServiceServer ¶
func (i *Infrastructure) AddServiceServer(serviceName string, addr Address) error
AddServiceServer registers server to a service in the infrastructure
func (*Infrastructure) MergeService ¶
func (i *Infrastructure) MergeService(name string, s Service)
MergeService in the infrastructure
func (*Infrastructure) RegisterService ¶
func (i *Infrastructure) RegisterService(name string, s Service) error
RegisterService in the infrastructure
func (*Infrastructure) RegisterServiceBatch ¶
func (i *Infrastructure) RegisterServiceBatch(m map[string]Service) error
RegisterServiceBatch registers services from given map[service name]Service Returns error if service already exists
func (*Infrastructure) RegisterServiceBatchIgnore ¶
func (i *Infrastructure) RegisterServiceBatchIgnore(m map[string]Service)
RegisterServiceBatchIgnore registers services from given map[service name]Service Ignores any error if service already exists
type Service ¶
type Service struct { Name string `json:"name"` Addresses []Address `json:"addresses"` Type ServiceType `json:"type"` }
Service defines an abstract service in infrastructure
type ServiceType ¶
type ServiceType string
ServiceType defines a type of protocol that service using
const ( // HTTP service type HTTP ServiceType = "http" // HTTPS service type HTTPS ServiceType = "https" // TCP service type TCP ServiceType = "tcp" // UDP service type UDP ServiceType = "udp" // Custom protocol service type Custom ServiceType = "custom" )
func GetTypeByString ¶
func GetTypeByString(typeName string) (ServiceType, error)
GetTypeByString returns a ServiceType associated with given typeName and nil, if type is known, otherwise instantiates a ServiceType with given typeName but returns ErrServiceTypeNotFound