behave

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextId

func NextId() uintptr

Types

type BaseScheduler

type BaseScheduler[T SchedulerEntry] struct {
	// contains filtered or unexported fields
}

type BaseSchedulerEntry

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

func (BaseSchedulerEntry) Frequency

func (b BaseSchedulerEntry) Frequency() int

func (BaseSchedulerEntry) Phase

func (b BaseSchedulerEntry) Phase() int

func (BaseSchedulerEntry) Schedulable

func (b BaseSchedulerEntry) Schedulable() Schedulable

type Delayed

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

type Dispatcher

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

func NewDispatcher

func NewDispatcher[T any]() *Dispatcher[T]

func (*Dispatcher[T]) Dispatch

func (d *Dispatcher[T]) Dispatch(
	sender Telegraph[T],
	receiver Telegraph[T],
	message T,
	delay bt.Optional[time.Duration],
	needsReturnReceipt bool,
)

func (*Dispatcher[T]) HandleMessage

func (d *Dispatcher[T]) HandleMessage(telegram Telegram[T]) bool

func (*Dispatcher) Identity

func (hi *Dispatcher) Identity() uintptr

func (*Dispatcher[T]) Listeners

func (d *Dispatcher[T]) Listeners() Registry[reflect.Type, Telegraph[T]]

func (*Dispatcher[T]) Providers

func (d *Dispatcher[T]) Providers() Registry[reflect.Type, TelegramProvider[T]]

type LoadBalancingScheduler

type LoadBalancingScheduler struct {
	BaseScheduler[BaseSchedulerEntry]
}

func (*LoadBalancingScheduler) Add

func (sch *LoadBalancingScheduler) Add(schedulable Schedulable, frequency int, phase bt.Optional[int])

func (*LoadBalancingScheduler) Run

func (sch *LoadBalancingScheduler) Run(ttl float32)

type PriorityScheduler

type PriorityScheduler struct {
	BaseScheduler[PrioritySchedulerEntry]
}

func (*PriorityScheduler) Add

func (sch *PriorityScheduler) Add(schedulable Schedulable, frequency int, phase bt.Optional[int])

func (*PriorityScheduler) AddPriority

func (sch *PriorityScheduler) AddPriority(schedulable Schedulable, priority float32, frequency int, phase bt.Optional[int])

func (*PriorityScheduler) Run

func (sch *PriorityScheduler) Run(ttl float32)

type PrioritySchedulerEntry

type PrioritySchedulerEntry struct {
	BaseSchedulerEntry
	// contains filtered or unexported fields
}

type Registry

type Registry[K, O any] interface {
	Get(key K) map[uintptr]O
	Add(id uintptr, obj O, key K)
	Remove(id uintptr, key K)
	RemoveAll(id uintptr)
	Clear(key K)
	ClearAll()
}

type ReturnReceipt

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

type Schedulable

type Schedulable interface {
	Run(ttl float32)
}

type Scheduler

type Scheduler interface {
	Schedulable
	Add(schedulable Schedulable, frequency int, phase bt.Optional[int])
}

type SchedulerEntry

type SchedulerEntry interface {
	Schedulable() Schedulable
	Frequency() int
	Phase() int
}

type SimpleRegistry

type SimpleRegistry[K comparable, O any] struct {
	// contains filtered or unexported fields
}

func NewSimpleRegistry

func NewSimpleRegistry[K, O comparable](addCallback func(O, K)) *SimpleRegistry[K, O]

func (*SimpleRegistry[K, O]) Add

func (r *SimpleRegistry[K, O]) Add(id uintptr, obj O, key K)

func (*SimpleRegistry[K, O]) Clear

func (r *SimpleRegistry[K, O]) Clear(key K)

func (*SimpleRegistry[K, O]) ClearAll

func (r *SimpleRegistry[K, O]) ClearAll()

func (*SimpleRegistry[K, O]) Get

func (r *SimpleRegistry[K, O]) Get(key K) map[uintptr]O

func (*SimpleRegistry[K, O]) Remove

func (r *SimpleRegistry[K, O]) Remove(id uintptr, key K)

func (*SimpleRegistry[K, O]) RemoveAll

func (r *SimpleRegistry[K, O]) RemoveAll(id uintptr)

type State

type State[E, T any] interface {
	Equals(o State[E, T]) bool
	Enter(entity bt.Optional[E])
	Update(entity bt.Optional[E])
	Exit(entity bt.Optional[E])
	OnMessage(entity bt.Optional[E], telegram Telegram[T]) bool
}

type StateMachine

type StateMachine[E, T any] struct {
	// contains filtered or unexported fields
}

func NewStateMachine

func NewStateMachine[E, T any](owner bt.Optional[E], initial, global bt.Optional[State[E, T]]) *StateMachine[E, T]

func (*StateMachine[E, T]) Change

func (sm *StateMachine[E, T]) Change(ns State[E, T])

func (*StateMachine[E, T]) Current

func (sm *StateMachine[E, T]) Current() bt.Optional[State[E, T]]

func (*StateMachine[E, T]) Global

func (sm *StateMachine[E, T]) Global() bt.Optional[State[E, T]]

func (*StateMachine[E, T]) HandleMessage

func (sm *StateMachine[E, T]) HandleMessage(telegram Telegram[T]) bool

func (*StateMachine) Identity

func (hi *StateMachine) Identity() uintptr

func (*StateMachine[E, T]) IsIn

func (sm *StateMachine[E, T]) IsIn(state State[E, T]) bool

func (*StateMachine[E, T]) Owner

func (sm *StateMachine[E, T]) Owner() bt.Optional[E]

func (*StateMachine[E, T]) Previous

func (sm *StateMachine[E, T]) Previous() bt.Optional[State[E, T]]

func (*StateMachine[E, T]) Revert

func (sm *StateMachine[E, T]) Revert() bool

func (*StateMachine[E, T]) Update

func (sm *StateMachine[E, T]) Update()

type Telegram

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

type TelegramProvider

type TelegramProvider[T any] interface {
	Identity() uintptr
	ProvideMessage(receiver Telegraph[T], messageType reflect.Type) bt.Optional[T]
}

type Telegraph

type Telegraph[T any] interface {
	Identity() uintptr
	HandleMessage(telegram Telegram[T]) bool
}

type TypeRegistry

type TypeRegistry[O any] struct {
	// contains filtered or unexported fields
}

func NewTypeRegistry

func NewTypeRegistry[O any](addCallback func(O, reflect.Type)) *TypeRegistry[O]

func (*TypeRegistry[O]) Add

func (r *TypeRegistry[O]) Add(id uintptr, obj O, key reflect.Type)

func (*TypeRegistry[O]) Clear

func (r *TypeRegistry[O]) Clear(key reflect.Type)

func (*TypeRegistry[O]) ClearAll

func (r *TypeRegistry[O]) ClearAll()

func (*TypeRegistry[O]) Get

func (r *TypeRegistry[O]) Get(key reflect.Type) map[uintptr]O

func (*TypeRegistry[O]) Remove

func (r *TypeRegistry[O]) Remove(id uintptr, key reflect.Type)

func (*TypeRegistry[O]) RemoveAll

func (r *TypeRegistry[O]) RemoveAll(id uintptr)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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