Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
func Clean()
Clean clears out the pre-registered values and channels uses for registration this method is primarily for testing and should not be used otherwise
func ID ¶
func ID(v interface{}) string
ID returns the registration id for the passed in object type
func Register ¶
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 ¶
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 string
Errors(buffer int) <-chan error
Properties(buffer int) (<-chan Properties, error)
Wait()
}
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, properties *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 identifier for the node that sent the electron
SenderID string `json:"senderid"`
// ID is the identifier of this electron
ID string `json:"id"`
// AtomID is the identifier of the atom for this electron instance
AtomID string `json:"atomid"`
// Timeout is the maximum time duration that should be allowed for this instance
// to process. After the duration is exceeded the context should be cancelled and
// the processing released and a failure sent back to the conductor
Timeout *time.Duration `json:"timeout,omitempty"`
// Payload is to be used by the registered atom to properly unmarshal
// the json for the actual atom instance. RawMessage is used to delay unmarshal
// of the payload information so the atom can do it internally
Payload json.RawMessage `json:"payload"`
}
Electron is the base electron that MUST parse from the payload from the conductor
type Properties ¶
type Properties struct {
ElectronID string `json:"electronId"`
AtomID string `json:"atomId"`
Start time.Time `json:"starttime"`
End time.Time `json:"endtime"`
Error error `json:"error"`
Result json.RawMessage `json:"result"`
}
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