Documentation
¶
Index ¶
- Constants
- Variables
- func GetManifestPath(id mtypes.LeaseID) string
- func LeaseEventsPath(id mtypes.LeaseID) string
- func LeasePath(id mtypes.LeaseID) string
- func LeaseShellPath(lID mtypes.LeaseID) string
- func LeaseStatusPath(id mtypes.LeaseID) string
- func MakeURI(uri *url.URL, path string) (string, error)
- func ServiceLogsPath(id mtypes.LeaseID) string
- func ServiceStatusPath(id mtypes.LeaseID, service string) string
- func StatusPath() string
- func SubmitManifestPath(dseq uint64) string
- func ValidatePath() string
- func VersionPath() string
- type BidEngineStatus
- type Client
- type ClientOption
- type ClientResponseError
- type ClusterStatus
- type EndpointMigrateRequestBody
- type ForwardedPortStatus
- type LeaseEvent
- type LeaseEventObject
- type LeaseKubeEvent
- type LeaseKubeEvents
- type LeaseShellResponse
- type LeaseStatus
- type LeasedIPStatus
- type ManifestStatus
- type MetricTotal
- type MigrateRequestBody
- type ProviderStatus
- type ReqClient
- type ServiceLogMessage
- type ServiceLogs
- type ServiceStatus
- type ValidateGroupSpecResult
Constants ¶
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 )
const ( LeaseShellCodeStdout = 100 LeaseShellCodeStderr = 101 LeaseShellCodeResult = 102 LeaseShellCodeFailure = 103 LeaseShellCodeStdin = 104 LeaseShellCodeTerminalResize = 105 )
const ( DeploymentPathPrefix = "/deployment/{dseq}" LeasePathPrefix = "/lease/{dseq}/{gseq}/{oseq}" HostnamePrefix = "/hostname" EndpointPrefix = "/endpoint" MigratePathPrefix = "/migrate" )
Variables ¶
var ( ErrNotInitialized = errors.New("rest: not initialized") ErrRPCClientNotSet = errors.New("rest: RPC client not set - use WithQueryClient option for on-chain operations") )
var (
ErrLeaseShellProviderError = fmt.Errorf("%w: the provider encountered an unknown error", errLeaseShell)
)
var ErrMutuallyExclusiveOptions = errors.New("WithProviderURL and WithQueryClient are mutually exclusive")
Functions ¶
func GetManifestPath ¶
func LeaseEventsPath ¶
func LeaseShellPath ¶
func LeaseStatusPath ¶
func ServiceLogsPath ¶
func StatusPath ¶
func StatusPath() string
func SubmitManifestPath ¶
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 ¶
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
- WithQueryClient: Set a query client for on-chain provider discovery (for on-chain operations)
- WithProviderURL: Set a provider URL directly (for off-chain operations)
Note: WithQueryClient and WithProviderURL are mutually exclusive. Auth options 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 (if provided) or use the direct URL 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 - Both WithQueryClient and WithProviderURL are provided - Neither WithQueryClient nor WithProviderURL are provided - The provider query fails (when using QueryClient) - 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.
func WithProviderURL ¶ added in v0.0.84
func WithProviderURL(providerURL string) ClientOption
WithProviderURL configures the client to use the specified provider URL directly. This option is mutually exclusive with WithQueryClient.
func WithQueryClient ¶ added in v0.0.84
func WithQueryClient(qclient aclient.QueryClient) ClientOption
WithQueryClient configures the client to use the specified query client for provider discovery. This option is mutually exclusive with WithProviderURL.
type ClientResponseError ¶
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 ¶
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 ¶
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 ServiceLogMessage ¶
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 ¶
ValidateGroupSpecResult represents the result of validating a group specification, including the minimum bid price required.