remote

package
v0.0.0-...-db7d511 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 7 Imported by: 7

Documentation

Overview

Package remote contains optional functionality. Interfaces and utilities will be in package remote, and implementation that depend on 3:rd party will be in sub-packages For example dependencies to event-bus implementations should not be manadatory. In case you want to use, for example NSQ,or NATS or something, then it should be easy to include the extra-package for that, and link in. If the utils in here grows too big, they will become their own repositorys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageReply

type MessageReply struct {
	MsgId   int64
	Seq     int64
	NumSeq  int64
	Payload []byte
	Error   string
}

The reply message to recieve

func MakeReplies

func MakeReplies(msgId int64, payload []byte) (ret []MessageReply)

func (*MessageReply) Encode

func (mr *MessageReply) Encode() ([]byte, error)

func (*MessageReply) Info

func (mr *MessageReply) Info() string

func (*MessageReply) String

func (mr *MessageReply) String() string

type PubSub

type PubSub interface {
	Pub(topic string, data []byte) error
	Sub(topic string, handler SubHandler) error
	Close() error
}

Generic PubSub interface.

type ReplySegmentChannel

type ReplySegmentChannel struct {
	Parts   []MessageReply
	Channel chan<- *MessageReply
}

func (*ReplySegmentChannel) SendIfComplete

func (rsc *ReplySegmentChannel) SendIfComplete(msg *MessageReply) (ok bool)

type ReplyableMessage

type ReplyableMessage struct {
	MsgId   int64
	ReplyTo string
	Payload []byte
}

Simple message with some metadata for reply

func (*ReplyableMessage) Encode

func (rm *ReplyableMessage) Encode() ([]byte, error)

type ReplyablePubSub

type ReplyablePubSub interface {
	PubSub
	Request(string, []byte) (*MessageReply, error)
}

func NewReplyablePubSub

func NewReplyablePubSub(ps PubSub) (rep ReplyablePubSub, err error)

func NewReplyablePubSubWithInbox

func NewReplyablePubSubWithInbox(ps PubSub, inbox string) (rep ReplyablePubSub, err error)

type RequestReplyChannel

type RequestReplyChannel func([]byte) ([]byte, error)

Bare function for request reply. Will be mapped 1 to 1 with a topic/endpoints.

func MakeRequestReplyChannel

func MakeRequestReplyChannel(rps ReplyablePubSub, topic string) RequestReplyChannel

A wrapper to make a RequestReplyChannel. It the rpc/eventbus has native request reply, then that implementation will have its own RequestReplyChannel creator.

type StreamTopicChannel

type StreamTopicChannel func(data []byte) error

func MakeStreamTopicChannel

func MakeStreamTopicChannel(ps PubSub, topic string) StreamTopicChannel

type SubHandler

type SubHandler interface {
	Handle(topic string, data []byte) error
}

Generic handler for subscriptions

func MakeSubReplyHandler

func MakeSubReplyHandler(ps PubSub, fn SubReplyHandlerHelperFn) SubHandler

A func to handle msg reply. Will only bee needed for pubsub's where it is not included.

type SubHandlerFn

type SubHandlerFn func(topic string, data []byte) error

func (SubHandlerFn) Handle

func (sh SubHandlerFn) Handle(topic string, data []byte) error

type SubReplyHandlerHelperFn

type SubReplyHandlerHelperFn func(topic string, msg []byte) ([]byte, error)

If we use this SubHandler function, then we will handle ReplyableMessage's, and can do basic RPC. We assume json encoding...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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