client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPartnerID = errors.New("partner id does not match")
)

Functions

func CreatePushSocket

func CreatePushSocket(url string) (mangos.Socket, error)

func CreateResponseWRP

func CreateResponseWRP(msg *wrp.Message) *wrp.Message

func ParseBus

func ParseBus(wrpBusOut chan wrp.Message, dataBusIn chan []byte, stopReading chan struct{}, logger log.Logger)

func ReadPump

func ReadPump(pullSock mangos.Socket, msgBus chan []byte, logger log.Logger)

func SendMessage

func SendMessage(sock mangos.Socket, msg wrp.Message) error

SendMessage will encode the message as msgpack and send the message. Note this is async. I couldn't find a way to make this synchronous.

func SetupFlagSet

func SetupFlagSet(fs *pflag.FlagSet) error

SetupFlagSet sets up some initial helper flags

func WritePump

func WritePump(pushSock mangos.Socket, bus chan wrp.Message, stopWriting chan struct{}, logger log.Logger)

Types

type AllowMessage

type AllowMessage interface {
	Allow(msg wrp.Message) error
}

AllowMessage is the interface to block request that come from talaria. If an error is returned, an unauthorized message will be sent with the error payload

type AllowMessageFunc

type AllowMessageFunc func(msg wrp.Message) error

AllowMessageFunc is the Allow function that a AllowMessage has.

func BlockByPartnerID

func BlockByPartnerID(partnerID string) AllowMessageFunc

BlockByPartnerID is a AllowMessageFunc to block request that don't have the associated device partnerID with the wrp request.

func (AllowMessageFunc) Allow

func (allowFunc AllowMessageFunc) Allow(msg wrp.Message) error

Allow runs the allowMessageFunc, making an AllowMessageFunc also an AllowMessage.

type ClientConfig

type ClientConfig struct {
	Name       string
	ParodusURL string
	ServiceURL string
	Debug      bool
	Logger     log.Logger
	MSGHandler kratos.DownstreamHandler
	Register   time.Duration
}

type SendMessageHandler

type SendMessageHandler interface {
	SendMessage(msg wrp.Message, c context.Context) error
}

func StartClient

func StartClient(config ClientConfig, lc fx.Lifecycle) (SendMessageHandler, error)

type SendMessageHandlerFunc

type SendMessageHandlerFunc func(msg wrp.Message, c context.Context) error

func (SendMessageHandlerFunc) SendMessage

func (sendMessageHandlerFunc SendMessageHandlerFunc) SendMessage(msg wrp.Message, c context.Context) error

Jump to

Keyboard shortcuts

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