Documentation ¶
Overview ¶
erl programming system
the `erl` package wraps channels in a Process based system inspired by Erlang and the Open Telecom Platform (OTP), which is the correct way to build an Actor system on top of CSP.
For now all of OTP and the `gen` behaviours are left out, but the core language primatives needed to build are implemented here:
- process - wraps user code and responds to signals
- monitor/demonitor signal - allows a process to be notified when the other process exits
- link/unlink signal - joins two processes and causes them both to exit if either one does
- Exit Trap - allows a process to ignore an exit signal and convert it to a message signal that is sent to the user code.
This all works, but the API here may change as we expand into OTP behaviours.
Index ¶
- func CancelTimer(tr TimerRef) error
- func DebugLogEnabled() bool
- func DebugPrintf(format string, v ...any)
- func DebugPrintln(v ...any)
- func Demonitor(self PID, ref Ref) bool
- func Exit(self PID, pid PID, reason *exitreason.S)
- func IsAlive(pid PID) bool
- func Link(self PID, pid PID)
- func NewTestReceiver(t *testing.T) (PID, *TestReceiver)deprecated
- func ProcessFlag(self PID, flag ProcFlag, value any)
- func Send(pid PID, term any)
- func SetDebugLog(v bool)
- func SpawnMonitor(self PID, r Runnable) (PID, Ref)
- func Unlink(self PID, pid PID)
- func Unregister(name Name) bool
- type Dest
- type DownMsg
- type ExitMsg
- type ILogger
- type Name
- type PID
- type PIDIface
- type ProcFlag
- type Process
- type Ref
- type Registration
- type RegistrationError
- type RegistrationErrorKind
- type Runnable
- type Signal
- type TestReceiver
- type TimerRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelTimer ¶ added in v0.8.1
func DebugLogEnabled ¶
func DebugLogEnabled() bool
func DebugPrintf ¶
func DebugPrintln ¶
func DebugPrintln(v ...any)
func Link ¶
A Link is a bi-directional relationship between two processes. Once established, an exit signal in one process will always be sent to the other process. If you prefer to handle the ExitMsg in the Runnable, then use ProcessFlag (TrapExit, true)
To remove a link use Unlink
func NewTestReceiver
deprecated
func NewTestReceiver(t *testing.T) (PID, *TestReceiver)
Deprecated: use [erltest.NewReceiver] as an alternative with the ability to set message expectations
func ProcessFlag ¶
func Send ¶
Sends the [term] to the process identified by [pid]. Will not error if process does not exist and will not block the caller.
func SetDebugLog ¶
func SetDebugLog(v bool)
func SpawnMonitor ¶
Types ¶
type ExitMsg ¶
type ExitMsg struct { // the process that sent the exit signal Proc PID Reason *exitreason.S // whether the exit was caused by a link. If false, then this was sent via [Exit()] Link bool }
type PID ¶
type PID struct {
// contains filtered or unexported fields
}
A Process Identifier; wraps the underlying Process so we can reference it without exposing Process internals or provide a named process registry in the future
func Spawn ¶
Creates a process and returns a PID that can be used to monitor or link to other process.
func (PID) ResolvePID ¶
TODO: might want to return an error if p.status != running?
type Ref ¶
type Ref string
an opaque unique string. Don't rely on structure format or even size for that matter.
func MakeRef ¶
func MakeRef() Ref
Returns an opqaue "unique" identifier. Not crypto unique. Callers should not depend on size and structure of the returned Ref
func Monitor ¶
This will establish a one-way relationship between [self] and [pid] and identified by the returned Ref. Once established, [self] will receive a DownMsg if the [pid] exits. Multiple Monitors between processes can be created (this is how synchronous communication between processes is handled)
type Registration ¶
func Registered ¶
func Registered() []Registration
type RegistrationError ¶
type RegistrationError struct {
Kind RegistrationErrorKind
}
func Register ¶
func Register(name Name, pid PID) *RegistrationError
func (*RegistrationError) Error ¶
func (e *RegistrationError) Error() string
type RegistrationErrorKind ¶
type RegistrationErrorKind string
const ( // process is already registered with given name AlreadyRegistered RegistrationErrorKind = "already_registered" // another process already registered given name NameInUse RegistrationErrorKind = "name_used" // the process you're trying to register doesn't exist/is dead NoProc RegistrationErrorKind = "no_proc" // name is invalid and cannot be registered. BadName RegistrationErrorKind = "bad_name" )
type TestReceiver ¶
type TestReceiver struct {
// contains filtered or unexported fields
}
func (*TestReceiver) Receiver ¶
func (tr *TestReceiver) Receiver() <-chan any
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
An application is a sort of root for a supervision tree.
|
An application is a sort of root for a supervision tree. |
this package contains the [TestReceiver] which is a process that can have message expectations set on them.
|
this package contains the [TestReceiver] which is a process that can have message expectations set on them. |
Each process should return a valid [exitreason.S] when it's [Runable.Receive] returns.
|
Each process should return a valid [exitreason.S] when it's [Runable.Receive] returns. |
gensrv provides a wrapper around [genserver] that removes the need for a callback struct, by using reflection to match callback arguments to functions.
|
gensrv provides a wrapper around [genserver] that removes the need for a callback struct, by using reflection to match callback arguments to functions. |
Package port provides a [Runnable] used to interact with external system processes (ExtProg).
|
Package port provides a [Runnable] used to interact with external system processes (ExtProg). |
find the project root at runtime
|
find the project root at runtime |
A recurringtask is similar to a cronjob; it is designed to be run on a soft schedule dictated by the [SetInterval] option.
|
A recurringtask is similar to a cronjob; it is designed to be run on a soft schedule dictated by the [SetInterval] option. |
WARNING: this package is EXPERIMENTAL and may change in breaking ways
|
WARNING: this package is EXPERIMENTAL and may change in breaking ways |