Documentation ¶
Index ¶
- Variables
- func AssertWorker(rawInput string) error
- func FindCurrencyAmountWorker(rawInput string) (string, error)
- func GenerateKeyWorker(rawInput string) (string, error)
- func HTTPRequestWorker(rawInput string) (string, error)
- func LoadEnvWorker(rawInput string) (string, error)
- func MathWorker(rawInput string) (string, error)
- func PopulateInput(state string, input string) (string, error)
- func PrintMessageWorker(message string)
- func RandomNumberWorker(rawInput string) (string, error)
- func RandomStringWorker(rawInput string) (string, error)
- type Error
- type Helper
- type Worker
- func (w *Worker) DeriveWorker(ctx context.Context, rawInput string) (string, error)
- func (w *Worker) FindBalanceWorker(ctx context.Context, dbTx database.Transaction, rawInput string) (string, error)
- func (w *Worker) GetBlobWorker(ctx context.Context, dbTx database.Transaction, rawInput string) (string, error)
- func (w *Worker) Process(ctx context.Context, dbTx database.Transaction, j *job.Job) (*job.Broadcast, *Error)
- func (w *Worker) ProcessNextScenario(ctx context.Context, dbTx database.Transaction, j *job.Job) *Error
- func (w *Worker) SaveAccountWorker(ctx context.Context, dbTx database.Transaction, rawInput string) error
- func (w *Worker) SetBlobWorker(ctx context.Context, dbTx database.Transaction, rawInput string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidJSON is returned when a populated value is not valid JSON. ErrInvalidJSON = errors.New("populated input is not valid JSON") // ErrVariableNotFound is returned when a variable is not // present in a Job's state. ErrVariableNotFound = errors.New("variable not found") // ErrJobComplete is returned when there are no more scenarios // to process in a Job. ErrJobComplete = errors.New("job complete") // ErrInvalidInput is returned when the input for an Action // cannot be parsed. ErrInvalidInput = errors.New("invalid input") // ErrInvalidActionType is returned when an Action has an unsupported // type. ErrInvalidActionType = errors.New("invalid action type") // ErrActionFailed is returned when Action exeuction fails with a valid input. ErrActionFailed = errors.New("action execution failed") // ErrCreateAccount is returned when a new account should // be created using the `create_account` workflow. ErrCreateAccount = errors.New("create account") // ErrUnsatisfiable is returned when there is no available // balance that can satisfy a FindBalance request. If there // are no pending broadcasts, this usually means that we need // to request funds. ErrUnsatisfiable = errors.New("unsatisfiable balance") )
Functions ¶
func AssertWorker ¶
AssertWorker checks if an input is < 0.
func FindCurrencyAmountWorker ¶
FindCurrencyAmountWorker finds a *types.Amount with a specific *types.Currency in a []*types.Amount.
func GenerateKeyWorker ¶
GenerateKeyWorker attempts to generate a key given a *GenerateKeyInput input.
func HTTPRequestWorker ¶
HTTPRequestWorker makes an HTTP request and returns the response to store in a variable. This is useful for algorithmic fauceting.
func LoadEnvWorker ¶
LoadEnvWorker loads an environment variable and stores it in state. This is useful for algorithmic fauceting.
func MathWorker ¶
MathWorker performs some MathOperation on 2 numbers.
func PopulateInput ¶
PopulateInput populates user defined variables in the input with their corresponding values from the execution state.
func PrintMessageWorker ¶
func PrintMessageWorker(message string)
PrintMessageWorker logs some message to stdout.
func RandomNumberWorker ¶
RandomNumberWorker generates a random number in the range [minimum,maximum).
func RandomStringWorker ¶
RandomStringWorker generates a string that complies with the provided regex input.
Types ¶
type Error ¶
type Error struct { Workflow string `json:"workflow"` Job string `json:"job"` Scenario string `json:"scenario"` ScenarioIndex int `json:"scenario_index"` ActionIndex int `json:"action_index"` Action *job.Action `json:"action,omitempty"` ProcessedInput string `json:"processed_input,omitempty"` Output string `json:"output,omitempty"` State string `json:"state"` Err error `json:"err"` }
Error is returned by worker execution.
type Helper ¶
type Helper interface { // StoreKey is called to persist a // *types.AccountIdentifier + KeyPair. StoreKey( context.Context, database.Transaction, *types.AccountIdentifier, *keys.KeyPair, ) error // AllAccounts returns a slice of all known *types.AccountIdentifier. AllAccounts( context.Context, database.Transaction, ) ([]*types.AccountIdentifier, error) // LockedAccounts is a slice of all *types.AccountIdentifier currently sending or receiving // funds. LockedAccounts( context.Context, database.Transaction, ) ([]*types.AccountIdentifier, error) // Balance returns the balance // for a provided address and currency. Balance( context.Context, database.Transaction, *types.AccountIdentifier, *types.Currency, ) (*types.Amount, error) // Coins returns all *types.Coin owned by an address. Coins( context.Context, database.Transaction, *types.AccountIdentifier, *types.Currency, ) ([]*types.Coin, error) // Derive returns a new *types.AccountIdentifier for a provided publicKey. Derive( context.Context, *types.NetworkIdentifier, *types.PublicKey, map[string]interface{}, ) (*types.AccountIdentifier, map[string]interface{}, error) // SetBlob transactionally persists // a key and value. SetBlob( ctx context.Context, dbTx database.Transaction, key string, value []byte, ) error // GetBlob transactionally retrieves // a key and value. GetBlob( ctx context.Context, dbTx database.Transaction, key string, ) (bool, []byte, error) }
Helper is used by the worker to process Jobs.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker processes jobs.
func (*Worker) DeriveWorker ¶
DeriveWorker attempts to derive an account given a *types.ConstructionDeriveRequest input.
func (*Worker) FindBalanceWorker ¶
func (w *Worker) FindBalanceWorker( ctx context.Context, dbTx database.Transaction, rawInput string, ) (string, error)
FindBalanceWorker attempts to find an account (and coin) with some minimum balance in a particular currency.
func (*Worker) GetBlobWorker ¶
func (w *Worker) GetBlobWorker( ctx context.Context, dbTx database.Transaction, rawInput string, ) (string, error)
GetBlobWorker transactionally retrieves a value associated with a key, if it exists.
func (*Worker) Process ¶
func (w *Worker) Process( ctx context.Context, dbTx database.Transaction, j *job.Job, ) (*job.Broadcast, *Error)
Process is called on a Job to execute the next available scenario. If no scenarios are remaining, this will return an error.
func (*Worker) ProcessNextScenario ¶
func (w *Worker) ProcessNextScenario( ctx context.Context, dbTx database.Transaction, j *job.Job, ) *Error
ProcessNextScenario performs the actions in the next available scenario.
func (*Worker) SaveAccountWorker ¶
func (w *Worker) SaveAccountWorker( ctx context.Context, dbTx database.Transaction, rawInput string, ) error
SaveAccountWorker saves a *types.AccountIdentifier and associated KeyPair in KeyStorage.
func (*Worker) SetBlobWorker ¶
func (w *Worker) SetBlobWorker( ctx context.Context, dbTx database.Transaction, rawInput string, ) error
SetBlobWorker transactionally saves a key and value for use across workflows.