rest

package
v0.0.82-eol.6 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PingWait Time allowed writing the file to the client.
	PingWait = 15 * time.Second

	// PongWait Time allowed reading the next pong message from the client.
	PongWait = 15 * time.Second

	// PingPeriod Send pings to a client with this period. Must be less than pongWait.
	PingPeriod = 10 * time.Second
)
View Source
const (
	LeaseShellCodeStdout         = 100
	LeaseShellCodeStderr         = 101
	LeaseShellCodeResult         = 102
	LeaseShellCodeFailure        = 103
	LeaseShellCodeStdin          = 104
	LeaseShellCodeTerminalResize = 105
)
View Source
const (
	DeploymentPathPrefix = "/deployment/{dseq}"
	LeasePathPrefix      = "/lease/{dseq}/{gseq}/{oseq}"
	HostnamePrefix       = "/hostname"
	EndpointPrefix       = "/endpoint"
	MigratePathPrefix    = "/migrate"
)

Variables

View Source
var (
	ErrLeaseShellProviderError = fmt.Errorf("%w: the provider encountered an unknown error", errLeaseShell)
)
View Source
var (
	ErrNotInitialized = errors.New("rest: not initialized")
)

Functions

func GetManifestPath

func GetManifestPath(id mtypes.LeaseID) string

func LeaseEventsPath

func LeaseEventsPath(id mtypes.LeaseID) string

func LeasePath

func LeasePath(id mtypes.LeaseID) string

func LeaseShellPath

func LeaseShellPath(lID mtypes.LeaseID) string

func LeaseStatusPath

func LeaseStatusPath(id mtypes.LeaseID) string

func MakeURI added in v0.0.82

func MakeURI(uri *url.URL, path string) (string, error)

MakeURI for client queries path must not include owner id

func ServiceLogsPath

func ServiceLogsPath(id mtypes.LeaseID) string

func ServiceStatusPath

func ServiceStatusPath(id mtypes.LeaseID, service string) string

func StatusPath

func StatusPath() string

func SubmitManifestPath

func SubmitManifestPath(dseq uint64) string

func ValidatePath

func ValidatePath() string

func VersionPath

func VersionPath() string

Types

type BidEngineStatus

type BidEngineStatus struct {
	Orders uint32 `json:"orders"`
}

BidEngineStatus represents the current state of the bid engine service, tracking the number of active orders.

type Client

type Client interface {
	NewReqClient(ctx context.Context) ReqClient
	Status(ctx context.Context) (*ProviderStatus, error)
	Validate(ctx context.Context, gspec dtypes.GroupSpec) (ValidateGroupSpecResult, error)
	SubmitManifest(ctx context.Context, dseq uint64, mani manifest.Manifest) error
	GetManifest(ctx context.Context, id mtypes.LeaseID) (manifest.Manifest, error)
	LeaseStatus(ctx context.Context, id mtypes.LeaseID) (LeaseStatus, error)
	LeaseEvents(ctx context.Context, id mtypes.LeaseID, services string, follow bool) (*LeaseKubeEvents, error)
	LeaseLogs(ctx context.Context, id mtypes.LeaseID, services string, follow bool, tailLines int64) (*ServiceLogs, error)
	ServiceStatus(ctx context.Context, id mtypes.LeaseID, service string) (*ServiceStatus, error)
	LeaseShell(ctx context.Context, id mtypes.LeaseID, service string, podIndex uint, cmd []string,
		stdin io.Reader,
		stdout io.Writer,
		stderr io.Writer,
		tty bool,
		tsq <-chan remotecommand.TerminalSize) error
	MigrateHostnames(ctx context.Context, hostnames []string, dseq uint64, gseq uint32) error
	MigrateEndpoints(ctx context.Context, endpoints []string, dseq uint64, gseq uint32) error
}

Client defines the methods available for connecting to the gateway server.

func NewClient

func NewClient(ctx context.Context, qclient aclient.QueryClient, addr sdk.Address, opts ...ClientOption) (Client, error)

NewClient creates and returns a new Client instance for interacting with the Akash provider.

It takes a context.Context for managing the lifecycle of operations, a QueryClient for making provider queries, the provider's address, and optional ClientOption functions for customizing the client configuration.

The following options can be provided.

  • WithAuthCerts: Configure TLS certificates for secure communication
  • WithAuthJWTSigner: Set a JWT signer for authentication
  • WithAuthToken: Provide an authentication token

Note, auth have the following priority: WithAuthCerts > WithAuthJWTSigner > WithAuthToken

The function will: 1. Apply any provided ClientOptions 2. Query the provider's host URI using the QueryClient 3. Set up TLS configuration with system certificates 4. Configure client authentication using either provided certificates or JWT signing

Returns an error if: - Any ClientOption fails to apply - The provider query fails - The host URI is invalid - System certificates cannot be loaded

type ClientOption

type ClientOption func(options *clientOptions) error

ClientOption is a function type that modifies a clientOptions struct and returns an error. It follows the functional options pattern for configuring the REST client.

ClientOption functions can be passed to client constructors to customize the client configuration. Common options include: - WithCerts: Configure TLS certificates for secure communication - WithJWTSigner: Set a JWT signer for authentication - WithToken: Provide an authentication token

If an error occurs while applying the option, it will be returned to the caller.

func WithAuthCerts

func WithAuthCerts(certs []tls.Certificate) ClientOption

WithAuthCerts configures the client with the provided TLS certificates for secure communication.

func WithAuthJWTSigner

func WithAuthJWTSigner(val ajwt.SignerI) ClientOption

WithAuthJWTSigner sets the JWT signer for authentication in the client.

func WithAuthToken

func WithAuthToken(val string) ClientOption

WithAuthToken provides an authentication token for the client.

type ClientResponseError

type ClientResponseError struct {
	Status  int
	Message string
}

func (ClientResponseError) ClientError

func (err ClientResponseError) ClientError() string

func (ClientResponseError) Error

func (err ClientResponseError) Error() string

type ClusterStatus

type ClusterStatus struct {
	Leases    uint32                       `json:"leases"`
	Inventory inventoryV1.InventoryMetrics `json:"inventory"`
}

ClusterStatus represents the current state of the provider's cluster, including the number of active leases and inventory metrics.

type EndpointMigrateRequestBody

type EndpointMigrateRequestBody struct {
	EndpointsToMigrate []string `json:"endpoints_to_migrate"`
	DestinationDSeq    uint64   `json:"destination_dseq"`
	DestinationGSeq    uint32   `json:"destination_gseq"`
}

EndpointMigrateRequestBody represents a request to migrate endpoints to a new deployment, including the list of endpoints and destination deployment/group sequence numbers.

type ForwardedPortStatus

type ForwardedPortStatus struct {
	Host         string                   `json:"host,omitempty"`
	Port         uint16                   `json:"port"`
	ExternalPort uint16                   `json:"externalPort"`
	Proto        manifest.ServiceProtocol `json:"proto"`
	Name         string                   `json:"name"`
}

ForwardedPortStatus represents the status of a forwarded port for a service, including host, port numbers, protocol, and service name.

type LeaseEvent

type LeaseEvent struct {
	Type                string           `json:"type" yaml:"type"`
	ReportingController string           `json:"reportingController,omitempty" yaml:"reportingController"`
	ReportingInstance   string           `json:"reportingInstance,omitempty" yaml:"reportingInstance"`
	Reason              string           `json:"reason" yaml:"reason"`
	Note                string           `json:"note" yaml:"note"`
	Object              LeaseEventObject `json:"object" yaml:"object"`
}

LeaseEvent represents an event that occurred in relation to a lease, including event type, reporting information, reason, and associated object.

type LeaseEventObject

type LeaseEventObject struct {
	Kind      string `json:"kind" yaml:"kind"`
	Namespace string `json:"namespace" yaml:"namespace"`
	Name      string `json:"name" yaml:"name"`
}

LeaseEventObject represents the object associated with a lease event, including its kind, namespace, and name.

type LeaseKubeEvent

type LeaseKubeEvent struct {
	Action  string `json:"action"`
	Message string `json:"message"`
}

LeaseKubeEvent represents a Kubernetes event related to a lease, including the action taken and associated message.

type LeaseKubeEvents

type LeaseKubeEvents struct {
	Stream  <-chan LeaseEvent
	OnClose <-chan string
}

LeaseKubeEvents represents a stream of Kubernetes events for a lease, including the event stream and a channel for close notifications.

type LeaseShellResponse

type LeaseShellResponse struct {
	ExitCode int    `json:"exit_code"`
	Message  string `json:"message,omitempty"`
}

LeaseShellResponse represents the response from a lease shell operation, including the exit code and any message.

type LeaseStatus

type LeaseStatus struct {
	Messages       []string                         `json:"errors,omitempty"`
	Services       map[string]*ServiceStatus        `json:"services"`
	ForwardedPorts map[string][]ForwardedPortStatus `json:"forwarded_ports"` // Container services that are externally accessible
	IPs            map[string][]LeasedIPStatus      `json:"ips"`
}

LeaseStatus represents the current state of a lease, including any error messages, service statuses, forwarded ports, and IP addresses.

type LeasedIPStatus

type LeasedIPStatus struct {
	Port         uint32
	ExternalPort uint32
	Protocol     string
	IP           string
}

LeasedIPStatus represents the status of an IP address leased to a service, including port numbers, protocol, and the IP address itself.

type ManifestStatus

type ManifestStatus struct {
	Deployments uint32 `json:"deployments"`
}

ManifestStatus represents the current state of the manifest service, tracking the number of active deployments.

type MetricTotal

type MetricTotal struct {
	CPU              uint64           `json:"cpu"`
	GPU              uint64           `json:"gpu"`
	Memory           uint64           `json:"memory"`
	StorageEphemeral uint64           `json:"storage_ephemeral"`
	Storage          map[string]int64 `json:"storage,omitempty"`
}

MetricTotal represents the total resource metrics across the cluster, including CPU, GPU, memory, ephemeral storage, and persistent storage.

type MigrateRequestBody

type MigrateRequestBody struct {
	HostnamesToMigrate []string `json:"hostnames_to_migrate"`
	DestinationDSeq    uint64   `json:"destination_dseq"`
	DestinationGSeq    uint32   `json:"destination_gseq"`
}

MigrateRequestBody represents a request to migrate hostnames to a new deployment, including the list of hostnames and destination deployment/group sequence numbers.

type ProviderStatus

type ProviderStatus struct {
	Cluster               *ClusterStatus   `json:"cluster"`
	Bidengine             *BidEngineStatus `json:"bidengine"`
	Manifest              *ManifestStatus  `json:"manifest"`
	ClusterPublicHostname string           `json:"cluster_public_hostname,omitempty"`
}

ProviderStatus represents the overall status of a provider, including cluster, bid engine, and manifest service states, along with the provider's public hostname.

type ReqClient added in v0.0.82

type ReqClient interface {
	DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (*websocket.Conn, *http.Response, error)
	Do(*http.Request) (*http.Response, error)
}

type ServiceLogMessage

type ServiceLogMessage struct {
	Name    string `json:"name"`
	Message string `json:"message"`
}

ServiceLogMessage represents a log message from a service, including the service name and the log message content.

type ServiceLogs

type ServiceLogs struct {
	Stream  <-chan ServiceLogMessage
	OnClose <-chan string
}

ServiceLogs represents a stream of log messages from services, including the log message stream and a channel for close notifications.

type ServiceStatus

type ServiceStatus struct {
	Name      string   `json:"name"`
	Available int32    `json:"available"`
	Total     int32    `json:"total"`
	URIs      []string `json:"uris"`

	ObservedGeneration int64 `json:"observed_generation"`
	Replicas           int32 `json:"replicas"`
	UpdatedReplicas    int32 `json:"updated_replicas"`
	ReadyReplicas      int32 `json:"ready_replicas"`
	AvailableReplicas  int32 `json:"available_replicas"`
}

ServiceStatus represents the current state of a service within a lease, including availability, total instances, URIs, and various replica counts.

type ValidateGroupSpecResult

type ValidateGroupSpecResult struct {
	MinBidPrice sdk.DecCoin `json:"min_bid_price"`
}

ValidateGroupSpecResult represents the result of validating a group specification, including the minimum bid price required.

Jump to

Keyboard shortcuts

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