Documentation
¶
Overview ¶
Package dispatch defines an interface for all password spraying implementations For example, a webhook worker client will send tasks to via HTTP requests. Additionally, this package provides a registration mechanism similar to database/sql. Make sure to "blank import" each dispatch.
import ( "github.com/praetorian-inc/trident/pkg/dispatch" _ "github.com/praetorian-inc/trident/pkg/dispatch/clients/webhook" ) var req event.AuthRequest // ... worker, err := dispatch.Open("webhook", map[string]string{"url":"https://example.org"}) if err != nil { // handle error } resp, err := worker.Submit(req) // ...
See https://golang.org/doc/effective_go.html#blank_import for more information on "blank imports".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher creates a data pipeline which accepts tasks, sends them to a worker, and publishes the result. This pipeline can be visualized as:
PubSub Subscription --> WorkerClient --> PubSub Topic
func NewDispatcher ¶
func NewDispatcher(ctx context.Context, opts Options, wc WorkerClient) (*Dispatcher, error)
NewDispatcher creates a dispatcher based on the provided options and worker.
type Driver ¶
type Driver interface {
New(opts map[string]string) (WorkerClient, error)
}
Driver is an interface which wraps the creation of a WorkerClient.
type Options ¶
type Options struct { // ProjectID is the Google Cloud Platform project ID ProjectID string // SubscriptionID is the Pub/Sub subscription used by the dispatcher to // listen for incoming tasks. SubscriptionID string // ResultTopicID is the Pub/Sub topic ID used by the dispatcher to publish // results.. ResultTopicID string }
Options is used to configure a Dispatcher
type WorkerClient ¶
type WorkerClient interface {
Submit(event.AuthRequest) (*event.AuthResponse, error)
}
WorkerClient is an interface that wraps the Submit function, which simply accepts and AuthRequest, performs work, and returns an AuthResponse.
func Open ¶
func Open(name string, opts WorkerOptions) (WorkerClient, error)
Open opens a worker client specified by the client driver name (e.g. webhook) and configures that client via the provided opts argument. Each WorkerClient should document its configuration options in its New() method.
type WorkerOptions ¶
WorkerOptions is a tyoe alias for simple marshaling/unmarshaling of worker configuration options.
func (*WorkerOptions) UnmarshalJSON ¶
func (opts *WorkerOptions) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the encoding/json.Unmarshaler interface.
func (*WorkerOptions) UnmarshalText ¶
func (opts *WorkerOptions) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.Textunmarshaler interface.