actor

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 2 Imported by: 1

README

actor

License MIT Go Reference Go Report Card

experiments

Documentation

Overview

Example
mailbox := make(chan any, 3)
callbacks := &actorHandler{stopped: make(chan struct{})}

Start[any](context.Background(), mailbox, callbacks)

mailbox <- 1
mailbox <- 2
mailbox <- 3

close(mailbox)
<-callbacks.stopped
Output:

processing message 1
processing message 2
processing message 3

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start[T any](ctx context.Context, mailbox Mailbox[T], callbacks Callbacks[T], options ...Option)

Types

type Callbacks

type Callbacks[T any] interface {
	Received(T)
	Stopped()
}

type Mailbox

type Mailbox[T any] <-chan T

type Option

type Option func(actorOptions) actorOptions

func WithAbsoluteTimeout

func WithAbsoluteTimeout(timeout time.Duration) Option

func WithIdleTimeout

func WithIdleTimeout(timeout time.Duration) Option

func WithRespawnAfter

func WithRespawnAfter(respawnAfter RequestCount) Option

type RequestCount

type RequestCount int

Jump to

Keyboard shortcuts

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