Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ID ¶
func ID(v interface{}) string
ID returns the registration id for the passed in object type
func Register ¶
func Register(values ...interface{}) error
Register adds entries of different types that are used by the atomizer and allows them to be pre-registered using an init script rather than having them passed in later at run time. This is useful for some situations where the user may not want to register explicitly
func Registrations ¶
func Registrations() []interface{}
Registrations returns a channel which contains the init pre-registrations for use by the atomizer
Types ¶
type Atom ¶
type Atom interface { Process( ctx context.Context, conductor Conductor, electron *Electron, ) ([]byte, error) }
Atom is an atomic action with process method for the atomizer to execute the Atom
type Atomizer ¶
type Atomizer interface { Exec() error Register(value ...interface{}) error Events(buffer int) <-chan interface{} Errors(buffer int) <-chan error Wait() // contains filtered or unexported methods }
Atomizer interface implementation
type Conductor ¶
type Conductor interface { // Receive gets the atoms from the source // that are available to atomize Receive(ctx context.Context) <-chan *Electron // Complete mark the completion of an electron instance // with applicable statistics Complete(ctx context.Context, p *Properties) error // Send sends electrons back out through the conductor for // additional processing Send(ctx context.Context, electron *Electron) (<-chan *Properties, error) // Close cleans up the conductor Close() }
Conductor is the interface that should be implemented for passing electrons to the atomizer that need processing. This should generally be registered with the atomizer in an initialization script
type Electron ¶
type Electron struct { // SenderID is the unique identifier for the node that sent the // electron SenderID string // ID is the unique identifier of this electron ID string // AtomID is the identifier of the atom for this electron instance // this is generally `package.Type`. Use the atomizer.ID() method // if unsure of the type for an Atom. AtomID string // Timeout is the maximum time duration that should be allowed // for this instance to process. After the duration is exceeded // the context should be canceled and the processing released // and a failure sent back to the conductor Timeout *time.Duration // CopyState lets atomizer know if it should copy the state of the // original atom registration to the new atom instance when processing // a newly received electron // // NOTE: Copying the state of an Atom as registered requires that ALL // fields that are to be copied are **EXPORTED** otherwise they are // skipped CopyState bool // Payload is to be used by the registered atom to properly unmarshal // the []byte for the actual atom instance. RawMessage is used to // delay unmarshal of the payload information so the atom can do it // internally Payload []byte }
Electron is the base electron that MUST parse from the payload from the conductor
func (*Electron) MarshalJSON ¶
MarshalJSON implements the custom json marshaler for electron
func (*Electron) UnmarshalJSON ¶
UnmarshalJSON reads in a []byte of JSON data and maps it to the Electron struct properly for use throughout Atomizer
type Error ¶
type Error struct { // Event is the event that took place to create // the error and contains metadata relevant to the error Event *Event `json:"event"` // Internal is the internal error Internal error `json:"internal"` }
Error is an error type which provides specific atomizer information as part of an error
type Event ¶
type Event struct { // Message from atomizer about this error Message string `json:"message"` // ElectronID is the associated electron instance // where the error occurred. Empty ElectronID indicates // the error was not part of a running electron instance. ElectronID string `json:"electronID"` // AtomID is the atom which was processing when // the error occurred. Empty AtomID indicates // the error was not part of a running atom. AtomID string `json:"atomID"` // ConductorID is the conductor which was being // used for receiving instructions ConductorID string `json:"conductorID"` }
Event indicates an atomizer event has taken place that is not categorized as an error Event implements the stringer interface but does NOT implement the error interface
type Properties ¶
type Properties struct { ElectronID string AtomID string Start time.Time End time.Time Error error Result []byte }
Properties is the struct for storing properties information after the processing of an atom has completed so that it can be sent to the original requestor
func (*Properties) Equal ¶
func (p *Properties) Equal(p2 *Properties) bool
Equal determines if two properties structs are equal to eachother TODO: Should this use reflect.DeepEqual?
func (*Properties) MarshalJSON ¶
func (p *Properties) MarshalJSON() ([]byte, error)
MarshalJSON implements the custom json marshaler for properties
func (*Properties) UnmarshalJSON ¶
func (p *Properties) UnmarshalJSON(data []byte) error
UnmarshalJSON reads in a []byte of JSON data and maps it to the Properties struct properly for use throughout Atomizer