routerclient

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: 17 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

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

DefaultClientConfig for router Client

View Source
var ErrDownlinkInactive = errors.New("Downlink stream not active")

ErrDownlinkInactive is returned by the Downlink func if downlink is inactive

Functions

This section is empty.

Types

type Client

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

Client for router

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 router server

func (*Client) Close

func (c *Client) Close()

Close the client and all its connections

func (*Client) NewGatewayStreams

func (c *Client) NewGatewayStreams(id string, token string, downlinkActive bool) GenericStream

NewGatewayStreams returns new streams using the given gateway ID and token

type ClientConfig

type ClientConfig struct {
	BackgroundContext context.Context
	BufferSize        int
}

ClientConfig for router Client

type GenericStream

type GenericStream interface {
	Uplink(*UplinkMessage)
	Status(*gateway.Status)
	Downlink() (<-chan *DownlinkMessage, error)
	Close()
}

GenericStream is used for sending to and receiving from the router.

type RouterStreamServer

type RouterStreamServer struct {
	UplinkChanFunc        func(md metadata.MD) (ch chan *UplinkMessage, err error)
	GatewayStatusChanFunc func(md metadata.MD) (ch chan *gateway.Status, err error)
	DownlinkChanFunc      func(md metadata.MD) (ch <-chan *DownlinkMessage, cancel func(), err error)
	// contains filtered or unexported fields
}

RouterStreamServer handles gRPC streams as channels

func NewRouterStreamServer

func NewRouterStreamServer() *RouterStreamServer

NewRouterStreamServer returns a new RouterStreamServer

func (*RouterStreamServer) GatewayStatus

func (s *RouterStreamServer) GatewayStatus(stream Router_GatewayStatusServer) error

GatewayStatus handles gateway status streams

func (*RouterStreamServer) SetLogger

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

SetLogger sets the logger

func (*RouterStreamServer) Subscribe

func (s *RouterStreamServer) Subscribe(req *SubscribeRequest, stream Router_SubscribeServer) (err error)

Subscribe handles downlink streams

func (s *RouterStreamServer) Uplink(stream Router_UplinkServer) (err error)

Uplink handles uplink streams

Jump to

Keyboard shortcuts

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