pubsub

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConsoleOpts = &Opts{
	Timeout: time.Minute * 120,
	Record:  true,
}
View Source
var DefaultOpts = &Opts{
	Timeout: 0,
	Record:  false,
}

Functions

func NewContext

func NewContext(parent context.Context, pubsub *PubSub) context.Context

NewContext returns a Context whose Value method returns the PubSub module.

func Unregister

func Unregister(c context.Context, key interface{})

Unregister performs a thread safe operation to delete the Channel with the given key.

Types

type Buffer

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

func NewBuffer

func NewBuffer(channel *Channel) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string) (n int, err error)

type Channel

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

func Lookup

func Lookup(c context.Context, key interface{}) *Channel

Lookup performs a thread safe operation to return a pointer to an existing Channel object with the given key. If the Channel does not exist a nil value is returned.

func NewChannel

func NewChannel(opts *Opts) *Channel

func Register

func Register(c context.Context, key interface{}) *Channel

Register performs a thread safe operation to return a pointer to a Channel object for the given key. The Channel is created if it does not yet exist.

func RegisterOpts

func RegisterOpts(c context.Context, key interface{}, opts *Opts) *Channel

Register performs a thread safe operation to return a pointer to a Channel object for the given key. The Channel is created if it does not yet exist using custom options.

func (*Channel) Close

func (c *Channel) Close()

func (*Channel) Publish

func (c *Channel) Publish(data interface{})

func (*Channel) Subscribe

func (c *Channel) Subscribe() *Subscription

type Opts

type Opts struct {
	// Timeout sets the expiration date for the channel,
	// at which time it will be closed and transmission will
	// stop. A zero value for means the channel will not timeout.
	Timeout time.Duration

	// Record indicates the channel should record the channel
	// activity and playback the full history to subscribers.
	Record bool
}

type PubSub

type PubSub struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func FromContext

func FromContext(c context.Context) *PubSub

FromContext returns the pool assigned to the context.

func NewPubSub

func NewPubSub() *PubSub

NewPubSub creates a new instance of the PubSub type and returns a pointer.

func (*PubSub) Lookup

func (b *PubSub) Lookup(key interface{}) *Channel

Lookup performs a thread safe operation to return a pointer to an existing Channel object with the given key. If the Channel does not exist a nil value is returned.

func (*PubSub) Register

func (b *PubSub) Register(key interface{}) *Channel

Register performs a thread safe operation to return a pointer to a Channel object for the given key. The Channel is created if it does not yet exist.

func (*PubSub) RegisterOpts

func (b *PubSub) RegisterOpts(key interface{}, opts *Opts) *Channel

Register performs a thread safe operation to return a pointer to a Channel object for the given key. The Channel is created if it does not yet exist using custom options.

func (*PubSub) Unregister

func (b *PubSub) Unregister(key interface{})

Unregister performs a thread safe operation to delete the Channel with the given key.

type Subscription

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

func NewSubscription

func NewSubscription(channel *Channel) *Subscription

func (*Subscription) Close

func (s *Subscription) Close()

func (*Subscription) CloseNotify

func (s *Subscription) CloseNotify() <-chan bool

func (*Subscription) Read

func (s *Subscription) Read() <-chan interface{}

Jump to

Keyboard shortcuts

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