eventpool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPassAlways

func FilterPassAlways(e events.Event) bool

FilterPassAlways event is always passable

func FilterPassLogoutEvents

func FilterPassLogoutEvents(e events.Event) bool

FilterPassLogoutEvents passes only LogoutEvents

Types

type EventChan

type EventChan struct {
	Ch chan events.Event

	// should return true if event should pass into channel
	Filter FilterPass
}

EventChan is used to determine if event can pass into channel custome FilterPass can be assigned, which returns true if event is passable

func NewEventChan

func NewEventChan() *EventChan

NewEventChan ...

func (*EventChan) WithFilter

func (ec *EventChan) WithFilter(filter FilterPass) *EventChan

WithFilter ...

type FilterPass

type FilterPass func(e events.Event) bool

FilterPass should return true if event is passable

func FilterPassIfUserInChat

func FilterPassIfUserInChat(chatDB db.ChatDB, username string) FilterPass

FilterPassIfUserInChat event is passable only if user is in same chat as event occurs in or if event global

type Pool

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

Pool ...

func NewPool

func NewPool() *Pool

NewPool ...

func (*Pool) CreateChan

func (p *Pool) CreateChan(filter FilterPass) <-chan events.Event

CreateChan creates chan with filter

func (*Pool) CreateChanNoFilter

func (p *Pool) CreateChanNoFilter() <-chan events.Event

CreateChanNoFilter creates chan with no filter

func (*Pool) GetInputChan

func (p *Pool) GetInputChan() chan<- events.Event

GetInputChan ...

func (*Pool) GetUserChan

func (p *Pool) GetUserChan(username string) <-chan events.Event

GetUserChan gets chan for user chans are created with default filter events.FilterPassIfUserInChat

func (*Pool) Run

func (p *Pool) Run()

Run ...

func (*Pool) WithUserChFilter

func (p *Pool) WithUserChFilter(f func(username string) FilterPass) *Pool

WithUserChFilter ...

Jump to

Keyboard shortcuts

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