Documentation
¶
Index ¶
- Constants
- func GetCancellationError(ctx context.Context) error
- func GetExitCode(ctx context.Context) int
- func Raise(ctx context.Context, e Event)
- func RegisterEventListener(ctx context.Context, f SetEventChanFunc)
- func SetExitCode(ctx context.Context, code int)
- func Stop(ctx context.Context)
- func Succeeded(ctx context.Context) bool
- func Success(ctx context.Context)
- func WithEvents(ctx context.Context) context.Context
- type ClientDisconnected
- type Event
- type File
- type HTTPRequest
- type HTTPRequestBody
- type HTTPResponse
- type SetEventChanFunc
Constants ¶
const ( // ExitCodeSuccess is the exit code for a successful run. ExitCodeSuccess = iota ExitCodeGenericFailure ExitCodeTimeoutFailure )
Variables ¶
This section is empty.
Functions ¶
func GetCancellationError ¶
func GetExitCode ¶
func RegisterEventListener ¶
func RegisterEventListener(ctx context.Context, f SetEventChanFunc)
func SetExitCode ¶
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 successful 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 (successful 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 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