Documentation ¶
Index ¶
- Constants
- func CreateErrorWRP(transaction string, dest string, src string, statusCode int64, err error) *wrp.Message
- func NewDecoderSender(sender registryHandler, maxWorkers int, queueSize int, logger log.Logger) *decoderQueue
- func NewDownstreamSender(senderFunc sendWRPFunc, maxWorkers int, queueSize int, logger log.Logger) *downstreamSenderQueue
- func NewEncoderSender(sender outboundSender, maxWorkers int, queueSize int, logger log.Logger) *encoderQueue
- func NewHandlerRegistry(config []HandlerConfig) (*handlerRegistry, error)
- func NewRegistryHandler(senderFunc sendWRPFunc, registry HandlerRegistry, ...) *registryQueue
- func NewSender(connection websocketConnection, maxWorkers int, queueSize int, ...) *senderQueue
- type Client
- type ClientConfig
- type DownstreamHandler
- type ErrInvalidHandler
- type ErrNoDownstreamHandler
- type HandlePingMiss
- type HandlerConfig
- type HandlerGroup
- type HandlerRegistry
- type Message
- type MessageBodyer
- type PingConfig
- type QueueConfig
- type StatusCoder
Constants ¶
const ( StatusDeviceDisconnected int = 523 StatusDeviceTimeout int = 524 )
Variables ¶
This section is empty.
Functions ¶
func CreateErrorWRP ¶
func NewDecoderSender ¶
func NewDecoderSender(sender registryHandler, maxWorkers int, queueSize int, logger log.Logger) *decoderQueue
NewDecoderSender creates a new decoderQueue for decoding and sending messages.
func NewDownstreamSender ¶
func NewDownstreamSender(senderFunc sendWRPFunc, maxWorkers int, queueSize int, logger log.Logger) *downstreamSenderQueue
NewDownstreamSender creates a new downstreamSenderQueue for asynchronously sending wrp messages downstream.
func NewEncoderSender ¶
func NewEncoderSender(sender outboundSender, maxWorkers int, queueSize int, logger log.Logger) *encoderQueue
NewEncoderSender creates a new encoderQueue, that allows for asynchronous sending outbound.
func NewHandlerRegistry ¶
func NewHandlerRegistry(config []HandlerConfig) (*handlerRegistry, error)
NewHandlerRegistry creates a handlerRegistry based on the initial handlers given.
func NewRegistryHandler ¶
func NewRegistryHandler(senderFunc sendWRPFunc, registry HandlerRegistry, downstreamSender downstreamSender, maxWorkers int, queueSize int, deviceID string, logger log.Logger) *registryQueue
NewRegistryHandler returns a registryHandler, which sends wrp messages to the correct handler in an asynchronous fashion.
Types ¶
type Client ¶
type Client interface { Hostname() string HandlerRegistry() HandlerRegistry Send(message *wrp.Message) Close() error }
Client is what function calls we expose to the user of kratos
func NewClient ¶
func NewClient(config ClientConfig) (Client, error)
NewClient is used to create a new kratos Client from a ClientConfig.
type ClientConfig ¶
type ClientConfig struct { DeviceName string FirmwareName string ModelName string Manufacturer string DestinationURL string Token string OutboundQueue QueueConfig WRPEncoderQueue QueueConfig WRPDecoderQueue QueueConfig HandlerRegistryQueue QueueConfig HandleMsgQueue QueueConfig TlsConfig *tls.Config Handlers []HandlerConfig HandlePingMiss HandlePingMiss ClientLogger log.Logger PingConfig PingConfig }
ClientConfig is the configuration to provide when making a new client.
type DownstreamHandler ¶
type DownstreamHandler interface { HandleMessage(msg *wrp.Message) *wrp.Message Close() }
DownstreamHandler should be implemented by the user so that they may deal with received messages how they please.
type ErrInvalidHandler ¶
type ErrInvalidHandler interface {
ErrInvalidHandler()
}
ErrInvalidHandler provides an easy way for a consumer to do logic based on the error of an invalid handler being found.
type ErrNoDownstreamHandler ¶
type ErrNoDownstreamHandler interface {
ErrNoDownstreamHandler()
}
ErrNoDownstreamHandler provides an easy way for a consumer to do logic based on the error of no downstream handler being found.
type HandlePingMiss ¶
type HandlePingMiss func() error
HandlePingMiss is a function called when we run into situations where we're not getting anymore pings. The implementation of this function needs to be handled by the user of kratos.
type HandlerConfig ¶
type HandlerConfig struct { Regexp string Handler DownstreamHandler }
HandlerConfig is the values that a consumer can set that specify the handler to use for the regular expression.
type HandlerGroup ¶
type HandlerGroup struct {
// contains filtered or unexported fields
}
HandlerGroup is an internal data type for Client interface that helps keep track of registered handler functions.
type HandlerRegistry ¶
type HandlerRegistry interface { Add(string, DownstreamHandler) error Remove(string) GetHandler(string) (DownstreamHandler, error) Close() }
HandlerRegistry is an interface that handles adding, getting, and removing DownstreamHandlers.
type MessageBodyer ¶
type MessageBodyer interface {
MessageBody() string
}
type PingConfig ¶
type QueueConfig ¶
QueueConfig is used to configure all the queues used to make kratos asynchronous.
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
statusCode follows the go-kit convention. Errors and other objects that implement this interface are allowed to supply an HTTP response status code.