Documentation ¶
Index ¶
- Constants
- func NewAgentEvent(sourceId string, eventType string, event interface{}) cloudevents.Event
- func StringOrNil(str string) *string
- type AgentClient
- func (a *AgentClient) DeployWorkload(request *DeployRequest) (*DeployResponse, error)
- func (a *AgentClient) Drain() error
- func (a *AgentClient) ExecTimeNanos() int64
- func (a *AgentClient) ID() string
- func (a *AgentClient) RecordExecTime(elapsedNanos int64)
- func (a *AgentClient) RunTrigger(ctx context.Context, tracer trace.Tracer, subject string, data []byte) (*nats.Msg, error)
- func (a *AgentClient) Start(agentID string) error
- func (a *AgentClient) Undeploy() error
- func (a *AgentClient) UptimeMillis() time.Duration
- type AgentStartedEvent
- type AgentStoppedEvent
- type DeployRequest
- type DeployResponse
- type EventCallback
- type ExecutionProviderParams
- type HandshakeCallback
- type HandshakeRequest
- type HandshakeResponse
- type HostServicesHTTPRequest
- type HostServicesHTTPResponse
- type HostServicesKeyValueResponse
- type HostServicesMessagingRequest
- type HostServicesMessagingResponse
- type HostServicesObjectStoreResponse
- type LogCallback
- type LogEntry
- type LogLevel
- type MachineMetadata
- type WorkloadStatusEvent
Constants ¶
const ( NexTriggerSubject = "x-nex-trigger-subject" NexRuntimeNs = "x-nex-runtime-ns" HttpURLHeader = "x-http-url" KeyValueKeyHeader = "x-keyvalue-key" MessagingSubjectHeader = "x-subject" ObjectStoreObjectNameHeader = "x-object-name" )
const ( AgentStartedEventType = "agent_started" AgentStoppedEventType = "agent_stopped" FunctionExecutionFailedType = "function_exec_failed" FunctionExecutionSucceededType = "function_exec_succeeded" WorkloadStartedEventType = "workload_started" // FIXME-- should this be WorkloadDeployed? WorkloadStoppedEventType = "workload_stopped" // FIXME-- should this be in addition to WorkloadUndeployed (likely yes, in case of something bad happening...) )
const ( LogLevelPanic = 0 LogLevelFatal = 1 LogLevelError = 2 LogLevelWarn = 3 LogLevelInfo = 4 LogLevelDebug = 5 LogLevelTrace = 6 )
const DefaultRunloopSleepTimeoutMillis = 25
DefaultRunloopSleepTimeoutMillis default number of milliseconds to sleep during execution runloops
const NexExecutionProviderELF = "elf"
Executable Linkable Format execution provider
const NexExecutionProviderOCI = "oci"
OCI execution provider
const NexExecutionProviderV8 = "v8"
V8 execution provider
const NexExecutionProviderWasm = "wasm"
Wasm execution provider
const WorkloadCacheBucket = "NEXCACHE"
Name of the internal, non-public bucket for sharing files between host and agent
Variables ¶
This section is empty.
Functions ¶
func NewAgentEvent ¶
func NewAgentEvent(sourceId string, eventType string, event interface{}) cloudevents.Event
Types ¶
type AgentClient ¶
type AgentClient struct {
// contains filtered or unexported fields
}
func NewAgentClient ¶
func NewAgentClient( nc *nats.Conn, log *slog.Logger, handshakeTimeout time.Duration, onTimedOut HandshakeCallback, onSuccess HandshakeCallback, onEvent EventCallback, onLog LogCallback, ) *AgentClient
func (*AgentClient) DeployWorkload ¶
func (a *AgentClient) DeployWorkload(request *DeployRequest) (*DeployResponse, error)
func (*AgentClient) Drain ¶
func (a *AgentClient) Drain() error
Stop the agent client instance and cleanup by draining subscriptions and releasing other associated resources
func (*AgentClient) ExecTimeNanos ¶
func (a *AgentClient) ExecTimeNanos() int64
func (*AgentClient) ID ¶
func (a *AgentClient) ID() string
Returns the ID of this agent client, which corresponds to a workload process identifier
func (*AgentClient) RecordExecTime ¶
func (a *AgentClient) RecordExecTime(elapsedNanos int64)
func (*AgentClient) RunTrigger ¶
func (*AgentClient) Start ¶
func (a *AgentClient) Start(agentID string) error
func (*AgentClient) Undeploy ¶
func (a *AgentClient) Undeploy() error
func (*AgentClient) UptimeMillis ¶
func (a *AgentClient) UptimeMillis() time.Duration
Returns the time difference between now and when the agent started
type AgentStartedEvent ¶
type AgentStartedEvent struct {
AgentVersion string `json:"agent_version"`
}
type AgentStoppedEvent ¶
type DeployRequest ¶
type DeployRequest struct { Argv []string `json:"argv,omitempty"` DecodedClaims jwt.GenericClaims `json:"-"` Description *string `json:"description"` Environment map[string]string `json:"environment"` Essential *bool `json:"essential,omitempty"` Hash string `json:"hash,omitempty"` Namespace *string `json:"namespace,omitempty"` RetriedAt *time.Time `json:"retried_at,omitempty"` RetryCount *uint `json:"retry_count,omitempty"` TotalBytes int64 `json:"total_bytes,omitempty"` TriggerSubjects []string `json:"trigger_subjects"` WorkloadName *string `json:"workload_name,omitempty"` WorkloadType *string `json:"workload_type,omitempty"` Stderr io.Writer `json:"-"` Stdout io.Writer `json:"-"` TmpFilename *string `json:"-"` EncryptedEnvironment *string `json:"-"` JsDomain *string `json:"-"` Location *url.URL `json:"-"` SenderPublicKey *string `json:"-"` TargetNode *string `json:"-"` WorkloadJwt *string `json:"-"` Errors []error `json:"errors,omitempty"` }
DeployRequest processed by the agent
func (*DeployRequest) IsEssential ¶
func (request *DeployRequest) IsEssential() bool
func (*DeployRequest) SupportsEssential ¶
func (request *DeployRequest) SupportsEssential() bool
Returns true if the run request supports essential flag
func (*DeployRequest) SupportsTriggerSubjects ¶
func (request *DeployRequest) SupportsTriggerSubjects() bool
Returns true if the run request supports trigger subjects
func (*DeployRequest) Validate ¶
func (r *DeployRequest) Validate() error
type DeployResponse ¶
type EventCallback ¶
type EventCallback func(string, cloudevents.Event)
type ExecutionProviderParams ¶
type ExecutionProviderParams struct { DeployRequest TriggerSubjects []string `json:"trigger_subjects"` // Fail channel receives bool upon command failing to start Fail chan bool `json:"-"` // Run channel receives bool upon command successfully starting Run chan bool `json:"-"` // Exit channel receives int exit code upon command exit Exit chan int `json:"-"` Stderr io.Writer `json:"-"` Stdout io.Writer `json:"-"` TmpFilename *string `json:"-"` VmID string `json:"-"` // NATS connection which be injected into the execution provider NATSConn *nats.Conn `json:"-"` }
ExecutionProviderParams parameters for initializing a specific execution provider
type HandshakeCallback ¶
type HandshakeCallback func(string)
type HandshakeRequest ¶
type HandshakeResponse ¶
type HandshakeResponse struct { }
type HostServicesHTTPRequest ¶
type HostServicesHTTPRequest struct { Method string `json:"method"` URL string `json:"url"` Body *string `json:"body,omitempty"` Headers *json.RawMessage `json:"headers,omitempty"` // FIXME-- this is very poorly named currently... //these params are parsed as an object and serialized as part of the query string Params *json.RawMessage `json:"params,omitempty"` }
type HostServicesHTTPResponse ¶
type HostServicesHTTPResponse struct { Status int `json:"status"` Headers *json.RawMessage `json:"headers,omitempty"` Body string `json:"body"` Error *string `json:"error,omitempty"` }
type HostServicesMessagingRequest ¶
type HostServicesMessagingRequest struct { Subject *string `json:"key"` Payload *json.RawMessage `json:"payload,omitempty"` }
type LogCallback ¶
type MachineMetadata ¶
type MachineMetadata struct { VmID *string `json:"vmid"` NodeNatsHost *string `json:"node_nats_host"` NodeNatsPort *int `json:"node_nats_port"` Message *string `json:"message"` Errors []error `json:"errors,omitempty"` }
func (*MachineMetadata) Validate ¶
func (m *MachineMetadata) Validate() bool