Documentation ¶
Index ¶
- 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 SetContinueInitProbe[STATE any](...) func(ts TestServer[STATE]) TestServer[STATE]
- func SetContinueProbe[STATE any](...) 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 CallReply
- type CallRequest
- type CallResult
- type CallReturnStatus
- type CastRequest
- type CastResult
- type ExitOpt
- type From
- type GenServer
- type GenServerS
- type InfoResult
- type InitResult
- type StartOpt
- type StartOpts
- 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, any, 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCallProbe ¶
func SetContinueInitProbe ¶ added in v0.8.0
func SetContinueInitProbe[STATE any](probe func(self erl.PID, state STATE) (newState STATE, continuation any, err error)) func(ts TestServer[STATE]) TestServer[STATE]
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 CallReply ¶ added in v0.11.0
type CallReply struct { Status CallReturnStatus Term any }
This is an intermediate response when invoking Call. Included here since it will appear in process inboxes and so needs to be matched in erl.TestReceiver
type CallRequest ¶ added in v0.11.0
intermediate message sent to GenServerS from Call. Not normally seen unless the receiver process in Call is not a GenServer
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 CallReturnStatus ¶ added in v0.11.0
type CallReturnStatus string
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" )
type CastRequest ¶ added in v0.11.0
type CastRequest struct {
Msg any
}
intermediate message sent to GenServerS from Cast. Not normally seen unless the receiver process in Cast is not a GenServer
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) // Handles Continuation terms from other callbacks. Set the [continueTerm] to re-enter the [HandleContinue] // callback with a new state HandleContinue(self erl.PID, continuation any, state STATE) (newState STATE, continueTerm any, err 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 StartOpt ¶
func InheritOpts ¶ added in v0.6.0
type StartOpts ¶ added in v0.6.0
type StartOpts interface { SetName(erl.Name) GetName() erl.Name SetStartTimeout(time.Duration) GetStartTimeout() time.Duration }
func DefaultOpts ¶ added in v0.7.0
func DefaultOpts() StartOpts
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, continuation any, 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) ContinueProbe func(self erl.PID, state STATE) (newState STATE, continuation any, err 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 (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.