Documentation ¶
Index ¶
- Constants
- Variables
- func NewParseError(code int, name, value string) error
- func ProtocolByName(name string) (api.ProtocolIdentifier, bool)
- func ProtocolName(p api.ProtocolIdentifier) string
- func ResolveProtocolAndTransport(p api.ProtocolIdentifier, t api.TransportIdentifier) (*ProtocolTransportOptions, *TransportInfo, error)
- func TransportByName(name string) (api.TransportIdentifier, bool)
- func TransportName(t api.TransportIdentifier) string
- type DiscoveryFunc
- type ListFunc
- type MessageFindFunc
- type MessageFunc
- func UntilCounter(count int, next MessageFunc) MessageFunc
- func UntilID(id uuid.UUID, exclusive bool, next MessageFunc) MessageFunc
- func UntilIndex(index int, exclusive bool, next MessageFunc) MessageFunc
- func UntilTime(time time.Time, exclusive bool, next MessageFunc) MessageFunc
- func WithPayload(matches [][]api.PayloadMatch, next MessageFunc) MessageFunc
- func WithServices(services []*api.ServiceKey, next MessageFunc) MessageFunc
- func WithStates(states []api.MessageState, next MessageFunc) MessageFunc
- type MessageLog
- type ParamFlags
- type ParamInfo
- type ParamType
- type Params
- type ParseError
- type ProtocolInfo
- type ProtocolTransportOptions
- type ResolveIDsInput
- type ResolveIDsOutput
- type Service
- type ServiceFunc
- type ServiceRegistry
- type ServiceStatus
- type Transport
- type TransportInfo
Constants ¶
const ( UnknownParamName = iota InvalidParamValue NoRequiredParam )
const ParamNameOpenAttemptsInterval = "openAttemptsInterval"
ParamNameOpenAttemptsInterval parameter name for the time interval between attempts to open (serial port)
const ParamNameOutgoingMaxTTL = "outgoingMaxTTL"
ParamNameOutgoingMaxTTL parameter name for the maximum time to live of outgoing messages
Variables ¶
var ( // ErrProtocolNotSupported is the error in case if provided protocol is not supported ErrProtocolNotSupported error = errors.New("the protocol is not supported") // ErrTransportNotSupported is the error in case if provided transport is not supported ErrTransportNotSupported error = errors.New("the transport is not supported") // ErrNoProtocolTransport is the error in case if provided transport is not supported for given protocol ErrNoProtocolTransport error = errors.New("the transport is not supported for the protocol") )
errors
var ( // ErrServiceExists is the error in case if service already exists ErrServiceExists error = errors.New("the service already exists") // ErrAliasExists is the error in case if service already exists ErrAliasExists error = errors.New("the service alias already exists") // ErrServiceNotExists returns if service is not exists (Remove, Status methods) ErrServiceNotExists error = errors.New("the service not exists") // ErrBadPayload returned by Send method in case if message's payload is not valid has no payload ErrBadPayload error = errors.New("the message's payload is not valid") // ErrSendBusy returned by Send method in case if service is unable to send message at this time ErrSendBusy error = errors.New("the service is too busy and unable to send the message") // ErrNoDiscovery returned by Discover method in case if service is not providing discovery function ErrNoDiscovery error = errors.New("no discovery service") // ErrDiscoveryBusy returned by Discover method in case if there are too many discovery requests are running ErrDiscoveryBusy error = errors.New("the discovery service is busy") // ErrNoDiscoveryID returned by Discovery method if discovery id is not found ErrNoDiscoveryID error = errors.New("the discovery id not found") // ErrDiscoveryPending returned by Discovery method if requested discovery query is not completed yet ErrDiscoveryPending error = errors.New("the discovery is not completed yet") )
errors
var ErrNotOpen error = errors.New("the transport entry is not open")
ErrNotOpen error
var ErrStatusGood error = errors.New("the service is functioning normally")
non-error service status
var Protocols map[api.ProtocolIdentifier]*ProtocolInfo
Protocols contains protocols definitions (defined in service module)
var Transports map[api.TransportIdentifier]*TransportInfo
Transports contains transports definitions (defined in services module)
Functions ¶
func NewParseError ¶
NewParseError creates new parse error
func ProtocolByName ¶
func ProtocolByName(name string) (api.ProtocolIdentifier, bool)
ProtocolByName resolves protocol name into identifier
func ProtocolName ¶
func ProtocolName(p api.ProtocolIdentifier) string
ProtocolName return name of the transport for provided identifier
func ResolveProtocolAndTransport ¶
func ResolveProtocolAndTransport(p api.ProtocolIdentifier, t api.TransportIdentifier) (*ProtocolTransportOptions, *TransportInfo, error)
ResolveProtocolAndTransport resolves protocol-transport pair
func TransportByName ¶
func TransportByName(name string) (api.TransportIdentifier, bool)
TransportByName resolves transport name into identifier
func TransportName ¶
func TransportName(t api.TransportIdentifier) string
TransportName return name of the transport for provided identifier
Types ¶
type DiscoveryFunc ¶
type DiscoveryFunc func(ctx context.Context, params api.ParamValues) ([]*api.DiscoveryEntry, error)
DiscoveryFunc is a method which returns discovered service entries or error
type ListFunc ¶
type ListFunc func(key *api.ServiceKey, alias string, status ServiceStatus, params api.ParamValues) bool
ListFunc is a the callback function used in ServiceRegistry List method. Returnning true will stop services iteration
type MessageFindFunc ¶
MessageFindFunc is a the callback function used in MessageLog to find first message in the List method
type MessageFunc ¶
MessageFunc is a the callback function used in MessageLog methods. Returnning true will stop messages iteration
func UntilCounter ¶
func UntilCounter(count int, next MessageFunc) MessageFunc
UntilCounter limits messages iteration by provided count
func UntilID ¶
func UntilID(id uuid.UUID, exclusive bool, next MessageFunc) MessageFunc
UntilID limits messages iteration by provided id, could be inclusive or exclusive
func UntilIndex ¶
func UntilIndex(index int, exclusive bool, next MessageFunc) MessageFunc
UntilIndex limits messages iteration by provided index, could be inclusive or exclusive
func UntilTime ¶
func UntilTime(time time.Time, exclusive bool, next MessageFunc) MessageFunc
UntilTime limits messages iteration by provided time, could be inclusive or exclusive
func WithPayload ¶
func WithPayload(matches [][]api.PayloadMatch, next MessageFunc) MessageFunc
WithPayload filters messages based on their payload
func WithServices ¶
func WithServices(services []*api.ServiceKey, next MessageFunc) MessageFunc
WithPayload filters messages based on their services
func WithStates ¶
func WithStates(states []api.MessageState, next MessageFunc) MessageFunc
WithPayload filters messages based on their state
type MessageLog ¶
type MessageLog interface { Persist() Register(key *api.ServiceKey, payload []byte, state api.MessageState) *api.Message UpdateState(id uuid.UUID, state api.MessageState) (*api.ServiceKey, *api.Message) Get(id uuid.UUID) (*api.ServiceKey, *api.Message) List(find MessageFindFunc, filter MessageFunc) int // non thread safe FromIndex(index int, exclusive bool) MessageFindFunc FromID(id uuid.UUID, exclusive bool) MessageFindFunc FromTime(time time.Time, exclusive bool) MessageFindFunc }
MessageLog defines message log interface
var Messages MessageLog
Messages provides access to MessageLog implementation (set in messages module)
type ParamFlags ¶
type ParamFlags uint8
ParamFlags type of parameter bit flags
const ( ParamFlagConst ParamFlags = 1 << iota ParamFlagRequired )
Parameter's bit flags
type ParamInfo ¶
type ParamInfo struct { Description string Type ParamType Flags ParamFlags DefaultValue string EnumValues []string }
ParamInfo parameter description
type ParamType ¶
type ParamType uint8
ParamType type of parameter type enum
type Params ¶
Params type defines named parameter collection
func (Params) ParseValues ¶
func (p Params) ParseValues(values api.RawParamValues) (api.ParamValues, error)
ParseValues function validates parameters and parses their value. Returns values map or parameter name + associated error
type ParseError ¶
ParseError is the structure which contains parameter parse error
func (*ParseError) Error ¶
func (pe *ParseError) Error() string
Error is the implementation of error interface
func (*ParseError) Is ¶
func (pe *ParseError) Is(target error) bool
type ProtocolInfo ¶
type ProtocolInfo struct { Name string Transports map[api.TransportIdentifier]*ProtocolTransportOptions }
ProtocolInfo protocol definition structure
type ProtocolTransportOptions ¶
type ProtocolTransportOptions struct { ServiceFunc // required Params // protocol parameters DiscoveryFunc // could be nil DiscoveryParams Params }
ProtocolTransportOptions defines transport options specific for the protocol
type ResolveIDsInput ¶
type ResolveIDsInput func() (key *api.ServiceKey, alias string, stop bool)
ResolveIDsInput is the input iteration method for ServiceREgistry ResoveIDs
type ResolveIDsOutput ¶
type ResolveIDsOutput func(key *api.ServiceKey, alias string)
ResolveIDsInput is the output method for ServiceREgistry ResoveIDs
type Service ¶
type Service interface { Start() Stop() Status() ServiceStatus Send(payload []byte) (*api.Message, error) }
Service interface, defines minimal set of methods the service needs to support
type ServiceFunc ¶
type ServiceFunc func(entry string, params api.ParamValues) (Service, error)
ServiceFunc is a method which creates service or returns error
type ServiceRegistry ¶
type ServiceRegistry interface { Discover(protocol api.ProtocolIdentifier, transport api.TransportIdentifier, params api.RawParamValues) (uuid.UUID, error) Discovery(id uuid.UUID, stop bool) ([]*api.DiscoveryEntry, error) Add(key *api.ServiceKey, params api.RawParamValues, alias string) error Alias(key *api.ServiceKey, oldAlias string, newAlias string) error Remove(key *api.ServiceKey, alias string) error Status(key *api.ServiceKey, alias string) (ServiceStatus, bool) List(listFn ListFunc) ResolveIDs(out ResolveIDsOutput, in ResolveIDsInput) Send(key *api.ServiceKey, alias string, payload []byte) (*api.Message, error) }
ServiceRegistry defines possible operations with services
var Services ServiceRegistry
Services provides access to ServiceRegistry implementation (set in services module)
type Transport ¶
type Transport interface { ID() api.TransportIdentifier Open(entry string, params api.ParamValues) error ReadyToRead() <-chan struct{} io.ReadWriteCloser }
Transport interface - blocking transport operations
type TransportInfo ¶
TransportInfo transport definition structure