statusbus

package
v0.0.0-...-0a8b275 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package statusbus collects and dispatches object rid status changes

It allows:

Post object rid status
Get object rid status

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorStarted   = errors.New("server already started")
	ErrorNeedStart = errors.New("server not started")
)

Functions

func WithContext

func WithContext(ctx context.Context, p naming.Path) (context.Context, func())

Types

type ObjT

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

func FromContext

func FromContext(ctx context.Context) *ObjT

func NewObjectBus

func NewObjectBus(p naming.Path) *ObjT

func (*ObjT) First

func (t *ObjT) First(rid string) status.T

func (*ObjT) Get

func (t *ObjT) Get(rid string) status.T

func (*ObjT) Pending

func (t *ObjT) Pending(rid string)

func (*ObjT) Post

func (t *ObjT) Post(rid string, state status.T, pending bool)

func (*ObjT) Register

func (t *ObjT) Register(rid string, hook func(status.T)) uuid.UUID

func (*ObjT) Unregister

func (t *ObjT) Unregister(rid string, u uuid.UUID)

func (*ObjT) Wait

func (t *ObjT) Wait(rid string, timeout time.Duration) status.T

type T

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

func (*T) First

func (t *T) First(p naming.Path, rid string) status.T

func (*T) Get

func (t *T) Get(p naming.Path, rid string) status.T

Get retrieve an object rid status

returns status.Undef if no object rid is not found

Example:

p := path.Path{Name:"foo",Namespace: "root", Kind: kind.Svc}
bus.Post(p, "app#1", status.Up)
bus.Post(p, "app#2", status.Down)

bus.Get(p, "app#1") // returns status.Up
bus.Get(p, "app#2") // returns status.Down
bus.Get(p, "app#99") // returns status.Undef
bus.Get(path.Path{}, "app#1") // returns status.Undef

func (*T) Pending

func (t *T) Pending(p naming.Path, rid string)

func (*T) Post

func (t *T) Post(p naming.Path, rid string, state status.T, pending bool)

Post push a new object rid status to status bus

bus.Post(naming.Path{Name:"foo",Namespace: "root", Kind: kind.Svc},

"app#1",
status.Down))

func (*T) Register

func (t *T) Register(p naming.Path, rid string, hook func(status.T)) uuid.UUID

func (*T) Start

func (t *T) Start()

Start run status bus listener go routine

bus := T{} defer bus.Stop() bus.Start()

func (*T) Stop

func (t *T) Stop()

Stop makes the status bus listener stops

func (*T) Unregister

func (t *T) Unregister(p naming.Path, rid string, u uuid.UUID)

func (*T) Wait

func (t *T) Wait(p naming.Path, rid string, timeout time.Duration) status.T

Jump to

Keyboard shortcuts

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