Documentation ¶
Index ¶
- Variables
- func Attach(managerName string, route string, f func(any, any) any) error
- func Await(managerName string, route string, data any) (any, error)
- func AwaitRequest(managerName string, request *Request) (any, error)
- func Detach(managerName string, route string) error
- func Kill(managerName string) error
- func KillAndRemove(managerName string) error
- func Remove(managerName string) error
- func SendRequest(managerName string, request *Request) error
- func Start(managerName string, managerState any) error
- type Manager
- func (manager *Manager) Attach(route string, function func(managerState any, request any) any)
- func (manager *Manager) Await(route string, data any) (any, error)
- func (manager *Manager) AwaitRequest(request *Request) (any, error)
- func (manager *Manager) Detach(route string)
- func (manager *Manager) IsRunning() bool
- func (manager *Manager) Kill() error
- func (manager *Manager) KillAndRemove() error
- func (manager *Manager) Remove() error
- func (manager *Manager) Send(route string, data any) *Request
- func (manager *Manager) SendRequest(request *Request)
- func (manager *Manager) Start(managerState any)
- type Request
- func (request *Request) Await(managerName string) (any, error)
- func (request *Request) AwaitManager(manager *Manager) (any, error)
- func (request *Request) HasData() bool
- func (request *Request) Send(managerName string) error
- func (request *Request) SendManager(manager *Manager)
- func (request *Request) Wait() (any, error)
Constants ¶
This section is empty.
Variables ¶
var LOG_PROCESSING_ERRORS = true
Used to determine whether or not errors which occurred during a manager processing
a function are logged to the console or not.
Functions ¶
func AwaitRequest ¶
Binding for manager.AwaitRequest() with the overhead of fetching manager by name.
func KillAndRemove ¶
Binding for manager.KillAndRemove() with the overhead of fetching manager by name.
func SendRequest ¶
Binding for manager.SendRequest() with the overhead of fetching manager by name.
Types ¶
type Manager ¶
type Manager struct { // Name is just a user defined name for the manager. This is the only public // value because it is not read anywhere internally, so we can pass it on to the users // to handle. Name string // contains filtered or unexported fields }
Manager is the struct used to process and respond to requests. The object itself is
quite simple. See below descriptions for what each attribute does.
func GetManager ¶
Simple function for fetching a manager by name
func NewManager ¶
NewManager will return a blank manager for use. Buffer size is the number of requests for the manager to hold onto until it starts blocking requests. The appropriate number will depend on how many requests you expect the manager to receive and how long each request takes to process.
func (*Manager) Attach ¶
Attach will attach a function to a manager at a specific route. Once a function is
attached, requests sent to the manager are able to find and use the function.
func (*Manager) Await ¶
Await will send a job to the manager and await completion. See Request.Await()
for a more detailed description of how this works.
func (*Manager) AwaitRequest ¶
AwaitRequest will queue a premade request to the manager. This is mainly just to ensure
that the .requests field can stay hidden.
func (*Manager) Detach ¶
Detach will remove a specified route from a manager. Once a function is detached,
requests sent to the manager will no longer be accessible.
func (*Manager) IsRunning ¶
IsRunning will just return the value of manager.running. Simple binding so that we
can ensure thread safety of manager attributes.
func (*Manager) Kill ¶
Kill is an internal request which will halt the manager. This is blocking and will wait
for the manager to actually stop processing. Just detach in a go-routine if you'd like to kill without waiting for a success.
func (*Manager) KillAndRemove ¶
Kill is a default request which will halt the manager AND remove it from the map
func (*Manager) Remove ¶
Remove is the function which will remove the manager from the public map.
Once this is done, the manager should be deleted/removed from memory.
func (*Manager) Send ¶
Send will send a job to the manager and not wait for completion. See Request.Send()
for a more detailed description of how this works.
func (*Manager) SendRequest ¶
SendRequest will queue a premade request to the manager. This is mainly just to ensure
that the .requests field can stay hidden and unaccessible to users. However, it can also be utilized if a user wishes to interact with it in a different way.
func (*Manager) Start ¶
Start will start the processing function for the manager. The for loop below is the
loop which handles the process. It's very straightforward. Just loop through and process each request as they come through until a kill request is sent. This function is blocking and you should detach it if you want the manager to function correctly.
type Request ¶
type Request struct { // Route is used to determine what this request is asking for. Route string // Data is the information being transferred during the request. Data any // contains filtered or unexported fields }
Request is the generic type used to communicate information to and from managers.
None of the data in request needs to be private as none of them have race conditions. unless maliciously used by others.
func NewRequest ¶
NewRequest will return a new request with the given Route and input Data.
The response channel will be appropriately generated as well. We default to length 1 channel because that's all we really need.
func (*Request) Await ¶
Binding for manager.AwaitRequest() with the overhead of fetching manager by name.
func (*Request) AwaitManager ¶
Inverse binding for manager.AwaitRequest().
func (*Request) HasData ¶
Check to see if the request has been carried out yet. As long as there are responses,
the request "has data"
func (*Request) Send ¶
Binding for manager.SendRequest() with the overhead of fetching manager by name.
func (*Request) SendManager ¶
Inverse binding for manager.SendRequest().