broker

package
v0.0.0-...-8c28d06 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package broker provides chat broker functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker represents chat broker

func New

func New(mq MQ, store ChatStore, ig Ingester) *Broker

New creates new chat broker instance

func (*Broker) Send

func (b *Broker) Send(chatID string, msg *goch.Message) error

Send sends new message to a given chat

func (*Broker) Subscribe

func (b *Broker) Subscribe(chatID, uid string, start uint64, c chan *goch.Message) (func(), error)

Subscribe subscribes to provided chat id at start sequence Returns close subscription func, or an error.

func (*Broker) SubscribeNew

func (b *Broker) SubscribeNew(chatID, uid string, c chan *goch.Message) (func(), error)

SubscribeNew subscribes to provided chat id subject starting from time.Now() Returns close subscription func, or an error.

type ChatStore

type ChatStore interface {
	UpdateLastClientSeq(string, string, uint64)
}

ChatStore represents chat store interface

type Ingester

type Ingester interface {
	Run(string) (func(), error)
}

Ingester represents chat history read model ingester

type MQ

type MQ interface {
	Send(string, []byte) error
	SubscribeSeq(string, string, uint64, func(uint64, []byte)) (io.Closer, error)
	SubscribeTimestamp(string, string, time.Time, func(uint64, []byte)) (io.Closer, error)
}

MQ represents message broker interface

Jump to

Keyboard shortcuts

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