event

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATA  byte = 0
	START byte = 1
	END   byte = 2
)

Variables

This section is empty.

Functions

func Listen

func Listen(s Stream, job Job)

func ListenWithContext

func ListenWithContext(s Stream, ctx context.Context, job Job)

func NewProvider

func NewProvider(capacity int, ctx context.Context) *provider

func NewProviderWithStream

func NewProviderWithStream(capacity int, s Stream, ctx context.Context) *provider

func NewStream

func NewStream() *stream

Types

type Event

type Event struct {
	Type  byte
	Error string
	Data  interface{}
}

func NewEndEvent

func NewEndEvent() Event

func NewEvent

func NewEvent(t byte, data interface{}, err error) Event

func NewStartEvent

func NewStartEvent() Event

type Job

type Job func(ctx context.Context, notify Notify)

type Notifier

type Notifier interface {
	Notify(data interface{})
}

type Notify

type Notify func(data interface{})

func (Notify) Notify

func (fn Notify) Notify(data interface{})

type Provider

type Provider interface {
	Notifier
	xnet.IDCode
	Start()
	Close()
	Sub(s Stream) (id string)
	Cancel(id string)
	CancelAll()
}

type Stream

type Stream interface {
	OnData(b []byte)
}

Jump to

Keyboard shortcuts

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