exec

package
v0.0.0-...-e687691 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventExec       = "exec"
	MaxLogBytes     = 1024 * 1024 * 32 // reasonably upper bound to write to s3 from 128mb lambda
	LogShipInterval = 1 * time.Second
)

Variables

View Source
var Rpc = map[string]rpcFunc{}

Functions

func Blake2b32

func Blake2b32(x string) string

func CaseInsensitiveGet

func CaseInsensitiveGet(m map[string]string, k string) (string, bool)

func Exec

func Exec(ctx context.Context, args *Args) (int, error)

if pushUrls are not provided, data will be persisted by aws-exec and this function will poll until process completion, pulling log data as it is available and invoking logDataCallback, then returning the exit code.

if pushUrls are provided, data will be persisted at those urls via http put with content-length set, and this function will return immediately. urls should remain valid for 20 minutes. log will be pushed repeatedly with the entire log contents. exit will be pushed once and will contain the exit code. size will be pushed once, will be pushed last, and will contain the size of the final log push.

func RandKey

func RandKey() string

func Tail

func Tail(ctx context.Context, tailArgs *TailArgs) (int, error)

if pushUrls were provided to Exec(), you can use Tail() to follow the output and return the exit code.

Types

type Args

type Args struct {
	Url             string
	Auth            string
	LogDataCallback func(logs string)
	PushUrls        *PushUrls

	// to invoke subprocess, provide argv. this is slower.
	Argv []string

	// to invoke rpc, provide name and args. this is faster.
	RpcName string
	RpcArgs string
}

type AsyncEvent

type AsyncEvent struct {
	EventType string    `json:"event-type"`
	AuthName  string    `json:"auth-name"`
	Uid       string    `json:"uid"`
	PushUrls  *PushUrls `json:"push-urls"`

	// to invoke subprocess, provide argv. this is slower.
	Argv []string `json:"argv"`

	// to invoke rpc, provide name and args. this is faster.
	RpcName string `json:"rpc-name"`
	RpcArgs string `json:"rpc-args"`
}

type GetRequest

type GetRequest struct {
	Uid        string `json:"uid"`
	RangeStart int    `json:"range-start"`
}

type GetResponse

type GetResponse struct {
	Exit *int   `json:"exit"`
	Url  string `json:"url"`
}

type PostRequest

type PostRequest struct {
	PushUrls *PushUrls `json:"push-urls"`

	// to invoke subprocess, provide argv. this is slower.
	Argv []string `json:"argv"`

	// to invoke rpc, provide name and args. this is faster.
	RpcName string `json:"rpc-name"`
	RpcArgs string `json:"rpc-args"`
}

type PostResponse

type PostResponse struct {
	Uid string `json:"uid"`
}

type PullKeys

type PullKeys struct {
	Log  string
	Size string
	Exit string
}

s3 keys to pull data from

type PushUrls

type PushUrls struct {
	Log  string `json:"log"`
	Size string `json:"size"`
	Exit string `json:"exit"`
}

s3 presigned put urls

type Record

type Record struct {
	RecordKey
	RecordData
}

type RecordData

type RecordData struct {
	Value string `json:"value"`
}

type RecordKey

type RecordKey struct {
	ID string `json:"id"`
}

type TailArgs

type TailArgs struct {
	PullBucket      string    // s3 bucket to pull data from
	PullKeys        *PullKeys // s3 keys to pull data from
	LogShipInterval time.Duration
	LogDataCallback func(logs string)
}

Jump to

Keyboard shortcuts

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