brokerclient

package
v0.0.0-...-228f33a Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 13 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClientConfig = ClientConfig{
	BackgroundContext: context.Background(),
	BufferSize:        10,
}

DefaultClientConfig for broker Client

Functions

This section is empty.

Types

type BrokerStreamServer

type BrokerStreamServer struct {
	RouterAssociateChanFunc  func(md metadata.MD) (up chan *UplinkMessage, down <-chan *DownlinkMessage, cancel func(), err error)
	HandlerSubscribeChanFunc func(md metadata.MD) (ch <-chan *DeduplicatedUplinkMessage, cancel func(), err error)
	HandlerPublishChanFunc   func(md metadata.MD) (ch chan *DownlinkMessage, err error)
	// contains filtered or unexported fields
}

BrokerStreamServer handles gRPC streams as channels

func NewBrokerStreamServer

func NewBrokerStreamServer() *BrokerStreamServer

NewBrokerStreamServer returns a new BrokerStreamServer

func (*BrokerStreamServer) Associate

func (s *BrokerStreamServer) Associate(stream Broker_AssociateServer) (err error)

Associate handles uplink streams from and downlink streams to the router

func (*BrokerStreamServer) Publish

func (s *BrokerStreamServer) Publish(stream Broker_PublishServer) error

Publish handles downlink streams from the handler

func (*BrokerStreamServer) SetLogger

func (s *BrokerStreamServer) SetLogger(logger log.Interface)

SetLogger sets the logger

func (*BrokerStreamServer) Subscribe

func (s *BrokerStreamServer) Subscribe(req *SubscribeRequest, stream Broker_SubscribeServer) (err error)

Subscribe handles uplink streams towards the handler

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for broker

func NewClient

func NewClient(config ClientConfig) *Client

NewClient creates a new Client with the given configuration

func (*Client) AddServer

func (c *Client) AddServer(name string, conn *grpc.ClientConn)

AddServer adds a broker server

func (*Client) Close

func (c *Client) Close()

Close the client and all its connections

func (*Client) NewHandlerStreams

func (c *Client) NewHandlerStreams(id string, token string) HandlerStream

NewHandlerStreams returns new streams using the given handler ID and token

func (*Client) NewRouterStreams

func (c *Client) NewRouterStreams(id string, token string) RouterStream

NewRouterStreams returns new streams using the given router ID and token

type ClientConfig

type ClientConfig struct {
	BackgroundContext context.Context
	BufferSize        int
}

ClientConfig for broker Client

type HandlerStream

type HandlerStream interface {
	Uplink() <-chan *DeduplicatedUplinkMessage
	Downlink(*DownlinkMessage)
	Close()
}

HandlerStream is used for sending uplink and receiving downlink.

type RouterStream

type RouterStream interface {
	Uplink(*UplinkMessage)
	Downlink() <-chan *DownlinkMessage
	Close()
}

RouterStream is used for sending uplink and receiving downlink.

Jump to

Keyboard shortcuts

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