pubysuby

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 3 Imported by: 1

README

pubysuby

In-memory message que in Go

To run the example chat in a browser

cd examples
go run main.go

To use PubySuby in your code

go get github.com/rambocoder/pubysuby

To test the code with race detector

./race.sh

License

pubysuby is available under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubySuby

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

func NewPubySuby

func NewPubySuby() *PubySuby

New creates a new PubySuby hub and starts a goroutine for handling commands

func (*PubySuby) LastMessageId

func (ps *PubySuby) LastMessageId(topic string) int64

Retrieves the last message posted to the que

func (*PubySuby) Pull

func (ps *PubySuby) Pull(topic string, timeout int64) []TopicItem

Pull all messages from the specified topic If none are in the topic, blocks for the timeout duration in milliseconds until new message is published

func (*PubySuby) PullSince

func (ps *PubySuby) PullSince(topic string, timeout int64, since int64) []TopicItem

Pull all messages from the specified topic If none are in the topic, blocks for the timeout duration in seconds until new message is published

func (*PubySuby) Push

func (ps *PubySuby) Push(topic string, message string) int64

Publishes the message to the topic and returns the message id

func (*PubySuby) Sub

func (ps *PubySuby) Sub(topic string) *Subscription

Subscribe to all new messages for a topic

func (*PubySuby) Unsubscribe

func (ps *PubySuby) Unsubscribe(subscription *Subscription)

type Subscription

type Subscription struct {
	TopicName     string
	ListenChannel chan []TopicItem
}

type Topic

type Topic struct {
	CommandChannel chan topicRequest
	// contains filtered or unexported fields
}

func NewTopic

func NewTopic(topicName string) *Topic

func (*Topic) GC

func (t *Topic) GC()

type TopicItem

type TopicItem struct {
	MessageId   int64
	Message     string
	CreatedTime time.Time
}

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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