event

package
v0.0.0-...-9f93016 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const StopCmd = "STOP"

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err struct {
	UUID uuid.UUID `json:"uuid"`
	Msg  string    `json:"msg"`
	Kind string    `json:"-"`
	Err  error     `json:"-"`
	Data any       `json:"data"`
}

type Evt

type Evt[T any] struct {
	// contains filtered or unexported fields
}

func (*Evt[T]) Pub

func (this *Evt[T]) Pub(ctx context.Context, event string, msg T) *Evt[T]

func (*Evt[T]) Sub

func (this *Evt[T]) Sub(event string, fn func(ctx context.Context, msg T)) int

func (*Evt[_]) Unsub

func (this *Evt[_]) Unsub(id int) error

type EvtChans

type EvtChans struct {
	NewReq chan Msg
	NewRes chan Msg
	Err    chan Err
	Sys    chan Sys
}

func (*EvtChans) New

func (this *EvtChans) New() *EvtChans

type HTTPErr

type HTTPErr struct {
	Req *http.Request `json:"-"`
}

type IEvt

type IEvt[T any] interface {
	Sub(event string, fn func(ctx context.Context, msg T)) int
	Unsub(id int) error
	Pub(ctx context.Context, event string, msg T) *Evt[T]
}

type Msg

type Msg struct {
	UUID uuid.UUID       `json:"uuid"`
	Ctx  context.Context `json:"-"` // not for public consumption
	Data any             `json:"data"`
}

type Sys

type Sys struct {
	Cmd string
}

Jump to

Keyboard shortcuts

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