Documentation
¶
Index ¶
- Constants
- func Call(self erl.PID, gensrv erl.Dest, request any, timeout time.Duration) (any, error)
- func Cast(gensrv erl.Dest, request any) error
- func Reply(client From, reply any)
- func SetArg[STATE any](arg any) func(tm TestMsg[STATE]) TestMsg[STATE]
- func SetCallProbe[STATE any](...) func(tm TestMsg[STATE]) TestMsg[STATE]
- func SetContinueProbe[STATE any](probe func(self erl.PID, state STATE) (newState STATE, err error)) func(tm TestMsg[STATE]) TestMsg[STATE]
- func SetInitProbe[STATE any](probe func(self erl.PID, args any) (STATE, any, error)) func(ts TestServer[STATE]) TestServer[STATE]
- func SetInitialState[STATE any](state STATE) func(ts TestServer[STATE]) TestServer[STATE]
- func SetProbe[STATE any](...) func(tm TestMsg[STATE]) TestMsg[STATE]
- func SetTermProbe[STATE any](probe func(self erl.PID, reason error, state STATE)) func(ts TestServer[STATE]) TestServer[STATE]
- func SetTestReceiver[STATE any](tr erl.PID) func(ts TestServer[STATE]) TestServer[STATE]
- func Start[STATE any](self erl.PID, callbackStruct GenServer[STATE], args any, opts ...StartOpt) (erl.PID, error)
- func StartLink[STATE any](self erl.PID, callbackStruct GenServer[STATE], args any, opts ...StartOpt) (erl.PID, error)
- func StartMonitor[STATE any](self erl.PID, callbackStruct GenServer[STATE], args any, opts ...StartOpt) (erl.PID, erl.Ref, error)
- func Stop(self erl.PID, gensrv erl.Dest, opts ...ExitOpt) error
- type CallResult
- type CastResult
- type ExitOpt
- type From
- type GenServer
- type GenServerS
- type InfoResult
- type InitResult
- type StartOpt
- type TestMsg
- type TestNotifCall
- type TestNotifCast
- type TestNotifContinue
- type TestNotifInfo
- type TestNotifInit
- type TestNotifTerminate
- type TestServer
- func (ts TestServer[STATE]) HandleCall(self erl.PID, request any, from From, state STATE) (CallResult[STATE], error)
- func (ts TestServer[STATE]) HandleCast(self erl.PID, request any, state STATE) (CastResult[STATE], error)
- func (ts TestServer[STATE]) HandleContinue(self erl.PID, continuation any, state STATE) (STATE, error)
- func (ts TestServer[STATE]) HandleInfo(self erl.PID, request any, state STATE) (InfoResult[STATE], error)
- func (ts TestServer[STATE]) Init(self erl.PID, args any) (InitResult[STATE], error)
- func (ts TestServer[STATE]) Terminate(self erl.PID, reason error, state STATE)
Constants ¶
View Source
const ( OK callReturnStatus = "ok" NoProc callReturnStatus = "noproc" Timeout callReturnStatus = "timeout" CallingSelf callReturnStatus = "calling_self" // supervisor stopped the GenServer Shutdown callReturnStatus = "shutdown" // genserver returned [Stop] without a reply. There may be a reason Stopped callReturnStatus = "normal_shutdown" // unhandled error happened. Other callReturnStatus = "other" )
Variables ¶
This section is empty.
Functions ¶
func SetCallProbe ¶
func SetContinueProbe ¶
func SetInitProbe ¶
func SetInitProbe[STATE any](probe func(self erl.PID, args any) (STATE, any, error)) func(ts TestServer[STATE]) TestServer[STATE]
func SetInitialState ¶
func SetInitialState[STATE any](state STATE) func(ts TestServer[STATE]) TestServer[STATE]
func SetTermProbe ¶
func SetTermProbe[STATE any](probe func(self erl.PID, reason error, state STATE)) func(ts TestServer[STATE]) TestServer[STATE]
func SetTestReceiver ¶
func SetTestReceiver[STATE any](tr erl.PID) func(ts TestServer[STATE]) TestServer[STATE]
func Start ¶
func Start[STATE any](self erl.PID, callbackStruct GenServer[STATE], args any, opts ...StartOpt) (erl.PID, error)
The [self] PID is required because the GenServer will notify it when [Init] is completed and will also call [Terminate] if the parent exits and the GenServer is trapping exits.
func StartLink ¶
func StartLink[STATE any](self erl.PID, callbackStruct GenServer[STATE], args any, opts ...StartOpt) (erl.PID, error)
see [StartError] for what type of error is returned.
func StartMonitor ¶
Types ¶
type CallResult ¶
type CallResult[STATE any] struct { // if true, then no reply will be sent to the caller. The genserver should reply with [genserver.Reply] // at a later time, otherwise the caller will time out. NoReply bool // The reply that will be sent to the caller Msg any // The updated state of the GenServer State STATE // if not nil, will call [HandleContinue] immmediately after [HandleCall] returns with this as the [continuation] Continue any }
type CastResult ¶
type ExitOpt ¶
type ExitOpt func(opts exitOptS) exitOptS
func StopReason ¶
func StopReason(e *exitreason.S) ExitOpt
func StopTimeout ¶
type GenServer ¶
type GenServer[STATE any] interface { Init(self erl.PID, args any) (InitResult[STATE], error) HandleCall(self erl.PID, request any, from From, state STATE) (CallResult[STATE], error) HandleCast(self erl.PID, request any, state STATE) (CastResult[STATE], error) HandleInfo(self erl.PID, msg any, state STATE) (InfoResult[STATE], error) HandleContinue(self erl.PID, continuation any, state STATE) (STATE, error) Terminate(self erl.PID, reason error, state STATE) }
type GenServerS ¶
type GenServerS[STATE any] struct { // contains filtered or unexported fields }
type InfoResult ¶
type InitResult ¶
type TestMsg ¶
type TestMsg[STATE any] struct { // probe can be used to inject functionality, reply back in cast requests, etc. Probe func(self erl.PID, arg any, state STATE) (cont any, newState STATE, err error) CallProbe func(self erl.PID, arg any, from From, state STATE) (call CallResult[STATE], err error) ContinueProbe func(self erl.PID, state STATE) (newState STATE, err error) Arg any }
type TestNotifCall ¶
type TestNotifCast ¶
type TestNotifContinue ¶
type TestNotifInfo ¶
type TestNotifInit ¶
type TestNotifTerminate ¶
type TestServer ¶
type TestServer[STATE any] struct { TermProbe func(self erl.PID, reason error, state STATE) InitProbe func(self erl.PID, args any) (STATE, any, error) InitialState STATE TestReceiver erl.PID }
func NewTestServer ¶
func NewTestServer[STATE any](opts ...func(ts TestServer[STATE]) TestServer[STATE]) TestServer[STATE]
func (TestServer[STATE]) HandleCall ¶
func (TestServer[STATE]) HandleCast ¶
func (ts TestServer[STATE]) HandleCast(self erl.PID, request any, state STATE) (CastResult[STATE], error)
func (TestServer[STATE]) HandleContinue ¶
func (ts TestServer[STATE]) HandleContinue(self erl.PID, continuation any, state STATE) (STATE, error)
func (TestServer[STATE]) HandleInfo ¶
func (ts TestServer[STATE]) HandleInfo(self erl.PID, request any, state STATE) (InfoResult[STATE], error)
func (TestServer[STATE]) Init ¶
func (ts TestServer[STATE]) Init(self erl.PID, args any) (InitResult[STATE], error)
Click to show internal directories.
Click to hide internal directories.