event

package
v0.0.0-...-9368c7e Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package event provides some primitives that are used for message passing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name EventName
	Resp Resp // channel to send an ack response on, nil to skip
	//Wg   *sync.WaitGroup // receiver barrier to Wait() for everyone else on
	Msg      string // some words for fun
	Activity bool   // did something interesting happen?
}

Event is the main struct that stores event information and responses.

func (*Event) ACK

func (event *Event) ACK()

ACK sends a single acknowledgement on the channel if one was requested.

func (*Event) ACKNACK

func (event *Event) ACKNACK(err error)

ACKNACK sends a custom ACK or NACK message on the channel if one was requested.

func (*Event) GetActivity

func (event *Event) GetActivity() bool

GetActivity returns the activity value.

func (*Event) NACK

func (event *Event) NACK()

NACK sends a negative acknowledgement message on the channel if one was requested.

type EventName

type EventName int

EventName represents the type of event being passed.

const (
	EventNil EventName = iota
	EventExit
	EventStart
	EventPause
	EventPoke
	EventBackPoke
)

The different event names are used in different contexts.

type Resp

type Resp chan error

Resp is a channel to be used for boolean responses. A nil represents an ACK, and a non-nil represents a NACK (false). This also lets us use custom errors.

func NewResp

func NewResp() Resp

NewResp is just a helper to return the right type of response channel.

func (Resp) ACK

func (resp Resp) ACK()

ACK sends a true value to resp.

func (Resp) ACKNACK

func (resp Resp) ACKNACK(err error)

ACKNACK sends a custom ACK or NACK. The ACK value is always nil, the NACK can be any non-nil error value.

func (Resp) ACKWait

func (resp Resp) ACKWait()

ACKWait waits for a +ive Ack from a Resp channel.

func (Resp) NACK

func (resp Resp) NACK()

NACK sends a false value to resp.

func (Resp) Wait

func (resp Resp) Wait() error

Wait waits for any response from a Resp channel and returns it.

Jump to

Keyboard shortcuts

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