provider

package
v1.0.138 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 3 Imported by: 0

README

Gravity Provider Interface

This package defines the minimal provider interface required by the gravity client.

Concrete implementations should be provided by consuming applications (e.g., hadron, other tools).

Interface

The Provider interface defines methods for:

  • Provisioning deployments
  • Deprovisioning deployments
  • Setting metrics collectors

Usage

Implement this interface in your application:

type MyProvider struct {
    // your fields
}

func (p *MyProvider) Provision(ctx context.Context, req *ProvisionRequest) (*Resource, error) {
    // your implementation
}

func (p *MyProvider) Deprovision(ctx context.Context, deploymentID string, reason DeprovisionReason) error {
    // your implementation
}

func (p *MyProvider) SetMetricsCollector(collector MetricsCollector) {
    // your implementation
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// Server is the gravity server that should be used
	Server Server
	// Context is the context that should be used for telemetry
	Context context.Context
	// Logger is the logger that should be used for telemetry
	Logger logger.Logger
	// APIURL is the url of the api server
	APIURL string
	// TelemetryURL is the url of the telemetry server
	TelemetryURL string
	// TelemetryAPIKey is the API key for the telemetry server (if needed)
	TelemetryAPIKey string
	// GravityURL is the url of the gravity server
	GravityURL string
	// AgentuityCACert is the ca cert of the gravity server
	AgentuityCACert string
	// HostMapping is the host mapping for the provider
	HostMapping []*pb.HostMapping
	// Environment is the environment for the provider
	Environment []string
	// SubnetRoutes
	SubnetRoutes []string
	// Hostname if the client requested a dynamic hostname
	Hostname string
	// OrgID is the organization ID for authentication
	OrgID string
	// SSHPublicKey is the public key for internal SSH authentication (SSH wire format)
	SSHPublicKey []byte
}

Configuration for provider setup

type DeprovisionReason

type DeprovisionReason string

DeprovisionReason specifies why a resource is being deprovisioned

const (
	DeprovisionReasonIdleTimeout DeprovisionReason = "idle_timeout"
	DeprovisionReasonError       DeprovisionReason = "error"
	DeprovisionReasonExited      DeprovisionReason = "exit"
	DeprovisionReasonShutdown    DeprovisionReason = "shutdown"
	DeprovisionReasonUnprovision DeprovisionReason = "unprovision"
)

type ProjectRuntimeStatsCollector

type ProjectRuntimeStatsCollector interface {
	UpdateRuntimeStats(deploymentID string, stats interface{})
	RemoveRuntimeStats(deploymentID string)
	PauseRuntimeStats(deploymentID string)
	UnpauseRuntimeStats(deploymentID string)
}

ProjectRuntimeStatsCollector interface for collecting project runtime statistics

type Provider

type Provider interface {
	// Configure will be called to configure the provider with the given configuration
	Configure(config Configuration) error

	// Deprovision deprovisions a provisioned resource
	Deprovision(ctx context.Context, resourceID string, reason DeprovisionReason) error

	// Resources returns a list of all resources regardless of state
	Resources() []*pb.ExistingDeployment

	// SetMetricsCollector sets the metrics collector for runtime stats collection
	SetMetricsCollector(collector ProjectRuntimeStatsCollector)

	// ProcessInPacket processes an inbound packet from the gravity server
	ProcessInPacket(payload []byte)
}

Provider interface defines the minimal set of methods required by the gravity client

type Server

type Server interface {
	// Unprovision is called to inform the server that we are unprovisioning the deployment
	Unprovision(deploymentID string) error
	// Pause is called to tell the server to pause sending provisioned events
	Pause(reason string) error
	// Resume is called to tell the server to resume sending provisioned events
	Resume(reason string) error
	// Write a packet to the gravity server
	WritePacket(payload []byte) error
}

Server interface for gravity server communication

Jump to

Keyboard shortcuts

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