client

package
v1.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: EPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrCodeLocalAPIStarting is returned when the daemon is up but the unix API listener is not ready.
	ErrCodeLocalAPIStarting = "LOCAL_API_STARTING"
	// ErrCodeDaemonUnavailable is returned when no edgelet daemon process is running.
	ErrCodeDaemonUnavailable = "DAEMON_UNAVAILABLE"
	// ErrCodeControllerOffline is returned when the local API is up but the controller is unreachable.
	ErrCodeControllerOffline = "CONTROLLER_OFFLINE"
)
View Source
const (
	// DefaultRequestTimeout is the per-request HTTP budget when --timeout is unset.
	DefaultRequestTimeout = 60 * time.Second
)

Variables

View Source
var ErrPollTimeout = &PollError{Message: "operation polling timed out"}

ErrPollTimeout indicates polling exceeded the configured timeout.

Functions

func AttachExecSession

func AttachExecSession(c *Client, selector, sessionID string) (int, error)

AttachExecSession attaches to an exec WebSocket session and streams stdin/stdout/stderr. Returns the remote command exit code when the session ends cleanly.

func ConfigureCLI

func ConfigureCLI(c *Client, timeoutFlag string)

ConfigureCLI applies CLI transport settings from the global --timeout flag. When set, --timeout overrides async poll totals only; per-request HTTP stays at DefaultRequestTimeout.

func DialWS

func DialWS(c *Client, path string) (*websocket.Conn, error)

DialWS opens a EdgeletAPI WebSocket using the same auth/dial behavior as the legacy CLI.

func OperationIDFromStart

func OperationIDFromStart(data map[string]any) string

OperationIDFromStart extracts an async operation id from a start response.

func ParseDurationFlag

func ParseDurationFlag(raw string) (time.Duration, bool)

ParseDurationFlag parses a Go duration string from the CLI --timeout flag.

func PollAsyncOperation

func PollAsyncOperation(ctx context.Context, cfg PollConfig, fetch func() (map[string]any, error), progress PollProgress) (map[string]any, []string, error)

PollAsyncOperation polls fetch until the operation reaches a terminal status. When StageFormatter is set, stage transitions are rendered on stderr. When PercentLabel is set, percent progress is rendered instead.

func PollTimeoutFor

func PollTimeoutFor(kind string) time.Duration

PollTimeoutFor returns the poll budget for an operation class, honoring --timeout when set.

func StreamMSLogs

func StreamMSLogs(c *Client, id, tail, since, until string, timestamps bool) error

StreamMSLogs follows microservice logs over WebSocket.

func StreamSystemLogs

func StreamSystemLogs(c *Client, tail, since, until string, timestamps bool) error

StreamSystemLogs follows daemon logs over WebSocket.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for communicating with the Edgelet API

func New

func New() *Client

New creates a new Edgelet API client.

func (*Client) IsDaemonRunning

func (c *Client) IsDaemonRunning() bool

IsDaemonRunning checks if the daemon is running First checks PID file, then tries Edgelet API connection

func (*Client) Request

func (c *Client) Request(method, path string, requestBody any) (map[string]any, error)

Request sends a typed request to EdgeletAPI v1 and returns JSON response map when possible.

func (*Client) RequestMultipartFile

func (c *Client) RequestMultipartFile(method, path, fileField, filePath string, fields map[string]string) (map[string]any, error)

RequestMultipartFile uploads a multipart manifest file with optional fields.

func (*Client) SetRequestTimeout

func (c *Client) SetRequestTimeout(timeout time.Duration)

SetRequestTimeout configures the per-request HTTP timeout for unix/TLS transports.

func (*Client) Token

func (c *Client) Token() string

Token returns the EdgeletAPI bearer token used for WebSocket auth.

type EdgeletAPI

type EdgeletAPI interface {
	Request(method, path string, requestBody any) (map[string]any, error)
	RequestMultipartFile(method, path, fileField, filePath string, fields map[string]string) (map[string]any, error)
	IsDaemonRunning() bool
}

EdgeletAPI is the EdgeletAPI v1 surface used by CLI client helpers.

type EdgeletAPIError

type EdgeletAPIError struct {
	StatusCode int
	Code       string
	Message    string
}

EdgeletAPIError is a structured EdgeletAPI v1 error.

func (*EdgeletAPIError) Error

func (e *EdgeletAPIError) Error() string

type PollConfig

type PollConfig struct {
	Interval    time.Duration
	Timeout     time.Duration
	PercentStep int
}

PollConfig controls async operation polling.

type PollError

type PollError struct {
	Message string
}

PollError is a polling failure.

func (*PollError) Error

func (e *PollError) Error() string

type PollProgress

type PollProgress struct {
	UI             *ui.UI
	Spinner        *ui.Spinner
	StageFormatter func(stage string) string
	PercentLabel   string
}

PollProgress configures stderr progress rendering during polling.

Jump to

Keyboard shortcuts

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