events

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExitCodeSuccess is the exit code for a successful run.
	ExitCodeSuccess = iota
	ExitCodeGenericFailure
	ExitCodeTimeoutFailure
)

Variables

This section is empty.

Functions

func GetCancellationError

func GetCancellationError(ctx context.Context) error

func GetExitCode

func GetExitCode(ctx context.Context) int

func Raise

func Raise(ctx context.Context, e Event)

func RegisterEventListener

func RegisterEventListener(ctx context.Context, f SetEventChanFunc)

func SetExitCode

func SetExitCode(ctx context.Context, code int)

func Stop

func Stop(ctx context.Context)

func Succeeded

func Succeeded(ctx context.Context) bool

func Success

func Success(ctx context.Context)

func WithEvents

func WithEvents(ctx context.Context) context.Context

Types

type ClientDisconnected

type ClientDisconnected struct {
	Err error
}

func (ClientDisconnected) Error

func (c ClientDisconnected) Error() string

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event represents events in oneshot that should be communicated to the user.

type File

type File struct {
	// Name is the name presented by the client.
	// This is not necessarily the name that the file will be save with.
	Name string `json:",omitempty"`
	// Path is the path the file was saved to.
	// This will only be set if the file was actually saved to disk.
	Path string `json:",omitempty"`
	MIME string `json:",omitempty"`
	// Size is the size of the file in bytes.
	// This may not always be set.
	Size int64 `json:",omitempty"`

	// TransferSize is the total size oneshot has read in / out.
	// For a succesfull file transfer, this will be equal to the size of the file.
	TransferSize      int64         `json:",omitempty"`
	TransferStartTime time.Time     `json:",omitempty"`
	TransferEndTime   time.Time     `json:",omitempty"`
	TransferDuration  time.Duration `json:",omitempty"`
	/// TransferRate is given in bytes / second
	TransferRate int64 `json:",omitempty"`

	Content any `json:",omitempty"`
}

File represents the file sent over by the client in the case of a transfer (send or receive)

func (*File) ComputeTransferFields

func (f *File) ComputeTransferFields()

ComputeTransferFields handles calculating field values that could not be obtained until after the transfer (succesfull or not), such as the duration.

type HTTPRequest

type HTTPRequest struct {
	Method     string              `json:",omitempty"`
	RequestURI string              `json:",omitempty"`
	Path       string              `json:",omitempty"`
	Query      map[string][]string `json:",omitempty"`
	Protocol   string              `json:",omitempty"`
	Header     map[string][]string `json:",omitempty"`
	Host       string              `json:",omitempty"`
	Trailer    map[string][]string `json:",omitempty"`
	RemoteAddr string              `json:",omitempty"`

	Body any `json:",omitempty"`
	// contains filtered or unexported fields
}

func NewHTTPRequest

func NewHTTPRequest(r *http.Request) *HTTPRequest

func NewHTTPRequest_WithBody

func NewHTTPRequest_WithBody(r *http.Request) *HTTPRequest

newHTTPRequest_WithBody replaces the requests body with a tee reader that copies the data into a byte buffer. This allows for the body to be written out later in a report should we need to.

func (*HTTPRequest) ReadBody

func (hr *HTTPRequest) ReadBody() error

ReadBody reads in the http requests body by calling body() if its not nil. the body func just reads in a buffered copy of the body; it will have already been read from the client point of view.

type HTTPRequestBody

type HTTPRequestBody func() ([]byte, error)

type HTTPResponse

type HTTPResponse struct {
	StatusCode int         `json:",omitempty"`
	Header     http.Header `json:",omitempty"`
	Body       any         `json:",omitempty"`
}

func (*HTTPResponse) ReadBody

func (hr *HTTPResponse) ReadBody() error

type SetEventChanFunc

type SetEventChanFunc func(context.Context, chan Event)

Jump to

Keyboard shortcuts

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