flow

package
v0.0.0-...-1ab713d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package flow provides GRR flow object which handles associated API calls via an arbitrary transfer protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PollPeriod

func PollPeriod(pollPeriod time.Duration) func(pollPeriodPtr *time.Duration)

PollPeriod is an optional argument that can be passed into Wait to set pollPeriod (time.Duration). Example usage could look like this: f.Wait(ctx, flow.PollPeriod(time.Duration(40)*time.Second)).

Types

type Connector

type Connector interface {
	GetFlowFilesArchive(ctx context.Context, args *afpb.ApiGetFlowFilesArchiveArgs) (io.ReadCloser, error)
	ListFlowResults(ctx context.Context, args *afpb.ApiListFlowResultsArgs, fn func(m *afpb.ApiFlowResult) error) (int64, error)
	CancelFlow(ctx context.Context, args *afpb.ApiCancelFlowArgs) error
	GetFlow(ctx context.Context, args *afpb.ApiGetFlowArgs) (*afpb.ApiFlow, error)
}

Connector abstracts GRR communication protocols (i.e. HTTP, Stubby).

type Flow

type Flow struct {
	ID       string
	ClientID string
	Data     *afpb.ApiFlow
	// contains filtered or unexported fields
}

Flow object is a helper object to send requests to GRR server via an arbitrary transfer protocol.

func NewFlow

func NewFlow(clientID string, id string, conn Connector) *Flow

NewFlow returns a new flow with given clientID, flow id and connector.

func (*Flow) Cancel

func (f *Flow) Cancel(ctx context.Context) error

Cancel sends a request to GRR server to cancel the flow.

func (*Flow) Get

func (f *Flow) Get(ctx context.Context) error

Get sends a request to GRR server to get information for a flow and fills it in Data field. If an error occurs, Data field will stay unchanged.

func (*Flow) GetFilesArchive

GetFilesArchive sends a request to GRR server to get files archive of the flow.

func (*Flow) ListResults

func (f *Flow) ListResults(ctx context.Context, fn func(r *Result) error) (int64, error)

ListResults sends a request to GRR server to list results of the flow.

func (*Flow) Wait

func (f *Flow) Wait(ctx context.Context, options ...func(pollPeriodPtr *time.Duration)) (*State, error)

Wait periodically pulls flow status from the server and returns when it's completed or context expires. It's users' responsibility to specify the WithDeadline/WithTimeout func for context. Example usage could look like this: ctx, cancel := context.WithTimeout(context.Background(), 10 * time.Minute) defer cancel() fs, err := flow.Wait(ctx)

type Result

type Result struct {
	Data *afpb.ApiFlowResult
}

Result wraps ApiFlowResult data.

func (*Result) Payload

func (r *Result) Payload() (proto.Message, error)

Payload returns the payload of a flow Result.

type State

type State struct {
	// an enum presenting the status of a flow.
	Name afpb.ApiFlow_State
	// a user-friendly status message.
	StatusText string
}

State contains a flow state (e.g. "RUNNING") and the completion status string for humans.

func (*State) HasFailed

func (fs *State) HasFailed() bool

HasFailed returns true if the flow somehow failed with a agent or server error.

func (*State) IsRunning

func (fs *State) IsRunning() bool

IsRunning returns true if the flow is still running.

func (*State) IsTerminated

func (fs *State) IsTerminated() bool

IsTerminated returns true if the flow has been completed and the actually performed on the agent.

Jump to

Keyboard shortcuts

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