broker

package
v0.0.71 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthenticationFailed = errors.New("authentication failed")
)

Functions

func EncodeSessionToken added in v0.0.64

func EncodeSessionToken(signKey string, tenant string, id string) (string, error)

Types

type Broker

type Broker struct {
	ID string

	Sessions SessionStore
	Queues   QueuesStore
	Messages *messages.Client
	// contains filtered or unexported fields
}

func New

func New(id string, logger *zap.Logger, mesh cluster.DiscoveryLayer, config Config) *Broker

func (*Broker) Authenticate

func (b *Broker) Authenticate(transport transport.Metadata, sessionID []byte, username string, password string) (tenant string, err error)

func (*Broker) CloseSession added in v0.0.32

func (b *Broker) CloseSession(ctx context.Context, token string) error

func (*Broker) Connect added in v0.0.51

func (b *Broker) Connect(ctx context.Context, metadata transport.Metadata, p *packet.Connect) (string, string, *packet.ConnAck, error)

func (*Broker) Disconnect added in v0.0.51

func (b *Broker) Disconnect(ctx context.Context, token string, p *packet.Disconnect) error

func (*Broker) Health added in v0.0.64

func (b *Broker) Health() string

func (*Broker) JoinServiceLayer added in v0.0.52

func (b *Broker) JoinServiceLayer(name string, logger *zap.Logger, config cluster.ServiceConfig, rpcConfig cluster.ServiceConfig, mesh cluster.DiscoveryLayer)

func (*Broker) PingReq added in v0.0.62

func (b *Broker) PingReq(ctx context.Context, id string, _ *packet.PingReq) (*packet.PingResp, error)

func (*Broker) Publish added in v0.0.51

func (b *Broker) Publish(ctx context.Context, token string, p *packet.Publish) (*packet.PubAck, error)

func (*Broker) Serve added in v0.0.52

func (b *Broker) Serve(port int) net.Listener

func (*Broker) Shutdown added in v0.0.52

func (b *Broker) Shutdown()

func (*Broker) SigningKey added in v0.0.64

func (b *Broker) SigningKey() string

func (*Broker) Subscribe added in v0.0.51

func (b *Broker) Subscribe(ctx context.Context, token string, p *packet.Subscribe) (*packet.SubAck, error)

func (*Broker) Unsubscribe added in v0.0.51

func (b *Broker) Unsubscribe(ctx context.Context, token string, p *packet.Unsubscribe) (*packet.UnsubAck, error)

type Config

type Config struct {
	AuthHelper func(transport transport.Metadata, sessionID []byte, username string, password string) (tenant string, err error)
	Session    SessionConfig
}

func DefaultConfig

func DefaultConfig() Config

type MessagesStore added in v0.0.71

type MessagesStore interface {
	Put(ctx context.Context, streamId string, shardKey string, payload []byte) error
}

type QueuesStore added in v0.0.69

type QueuesStore interface {
	Create(ctx context.Context, id string) error
	Delete(ctx context.Context, id string) error
}

type SessionConfig added in v0.0.9

type SessionConfig struct {
	MaxInflightSize int
}

type SessionStore

type SessionStore interface {
	RefreshKeepAlive(ctx context.Context, id string, timestamp int64) error
}

type Token added in v0.0.64

type Token struct {
	SessionID     string `json:"session_id"`
	SessionTenant string `json:"session_tenant"`
	jwt.StandardClaims
}

func DecodeSessionToken added in v0.0.64

func DecodeSessionToken(signKey string, signedToken string) (Token, error)

type TopicStore

type TopicStore interface {
	ByTopicPattern(ctx context.Context, tenant string, pattern []byte) ([]*topics.RetainedMessage, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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