flaps

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: Apache-2.0 Imports: 24 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlapsErrorNotFound = &FlapsError{ResponseStatusCode: http.StatusNotFound}
)
View Source
var NonceHeader = "fly-machine-lease-nonce"

Functions

func GetErrorRequestID

func GetErrorRequestID(err error) string

func GetErrorTraceID added in v0.1.5

func GetErrorTraceID(err error) string

func Retry added in v0.1.19

func Retry(ctx context.Context, op func() error) error

Retry the given operation with exponential backoff up to 1 minute.

Types

type App added in v0.1.67

type App struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	InternalNumericID int32  `json:"internal_numeric_id"`
	Network           string `json:"network"`
	Status            string `json:"status"`

	MachineCount int64 `json:"machine_count"`
	VolumeCount  int64 `json:"volume_count"`

	Organization AppOrganizationInfo `json:"organization"`

	// hashid.appname.fly.dev, for ACME HTTP-01 pointing only to v6
	CnameTarget string `json:"cname_target"`
	// a role like "postgres_cluster" or "remote-docker-builder"
	AppRole string `json:"app_role"`
}

func (*App) Deployed added in v0.1.67

func (a *App) Deployed() bool

func (*App) IsPostgresApp added in v0.1.67

func (a *App) IsPostgresApp() bool

type AppOrganizationInfo added in v0.1.67

type AppOrganizationInfo struct {
	Name              string `json:"name"`
	Slug              string `json:"slug"`
	InternalNumericID int32  `json:"internal_numeric_id"`
}

type AssignIPRequest added in v0.1.67

type AssignIPRequest struct {
	Type         string `json:"type"`
	Region       string `json:"region"`
	Organization string `json:"org_slug"`
	Network      string `json:"network"`
	ServiceName  string `json:"service_name"`
}

type Client

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

func NewWithOptions

func NewWithOptions(ctx context.Context, opts NewClientOpts) (*Client, error)

func (*Client) AcquireLease

func (f *Client) AcquireLease(ctx context.Context, appName, machineID string, ttl *int) (*fly.MachineLease, error)

func (*Client) AppNameAvailable added in v0.1.67

func (f *Client) AppNameAvailable(ctx context.Context, name string) (ok bool, err error)

func (*Client) AssignIP added in v0.1.67

func (f *Client) AssignIP(ctx context.Context, appName string, req AssignIPRequest) (res *IPAssignment, err error)

func (*Client) Cordon

func (f *Client) Cordon(ctx context.Context, appName, machineID string, nonce string) (err error)

func (*Client) CreateApp

func (f *Client) CreateApp(ctx context.Context, in CreateAppRequest) (app *App, err error)

func (*Client) CreateVolume

func (f *Client) CreateVolume(ctx context.Context, appName string, req fly.CreateVolumeRequest) (*fly.Volume, error)

func (*Client) CreateVolumeSnapshot

func (f *Client) CreateVolumeSnapshot(ctx context.Context, appName, volumeId string) error

func (*Client) DecryptSecretKey added in v0.1.46

func (f *Client) DecryptSecretKey(ctx context.Context, appName, name string, ciphertext, assoc []byte, version *uint64) (*fly.DecryptSecretKeyResp, error)

func (*Client) DeleteApp added in v0.1.67

func (f *Client) DeleteApp(ctx context.Context, name string) error

func (*Client) DeleteAppSecret added in v0.1.46

func (f *Client) DeleteAppSecret(ctx context.Context, appName, name string) (*fly.DeleteAppSecretResp, error)

func (*Client) DeleteIPAssignment added in v0.1.67

func (f *Client) DeleteIPAssignment(ctx context.Context, appName, ip string) (err error)

func (*Client) DeleteMetadata

func (f *Client) DeleteMetadata(ctx context.Context, appName, machineID, key string) error

func (*Client) DeleteSecretKey added in v0.1.46

func (f *Client) DeleteSecretKey(ctx context.Context, appName, name string) error

func (*Client) DeleteVolume

func (f *Client) DeleteVolume(ctx context.Context, appName, volumeId string) (*fly.Volume, error)

func (*Client) Destroy

func (f *Client) Destroy(ctx context.Context, appName string, input fly.RemoveMachineInput, nonce string) (err error)

func (*Client) EncryptSecretKey added in v0.1.46

func (f *Client) EncryptSecretKey(ctx context.Context, appName, name string, plaintext, assoc []byte, version *uint64) (*fly.EncryptSecretKeyResp, error)

func (*Client) Exec

func (f *Client) Exec(ctx context.Context, appName, machineID string, in *fly.MachineExecRequest) (*fly.MachineExecResponse, error)

func (*Client) ExtendVolume

func (f *Client) ExtendVolume(ctx context.Context, appName, volumeId string, size_gb int) (*fly.Volume, bool, error)

func (*Client) FindLease

func (f *Client) FindLease(ctx context.Context, appName, machineID string) (*fly.MachineLease, error)

func (*Client) GenerateSecretKey added in v0.1.46

func (f *Client) GenerateSecretKey(ctx context.Context, appName, name string, typ string) (*fly.SetSecretKeyResp, error)

func (*Client) Get

func (f *Client) Get(ctx context.Context, appName, machineID string) (*fly.Machine, error)

func (*Client) GetAllVolumes

func (f *Client) GetAllVolumes(ctx context.Context, appName string) ([]fly.Volume, error)

func (*Client) GetApp added in v0.1.67

func (f *Client) GetApp(ctx context.Context, name string) (app *App, err error)

func (*Client) GetAppSecrets added in v0.1.46

func (f *Client) GetAppSecrets(ctx context.Context, appName, name string, version *uint64, showSecrets bool) (*fly.AppSecret, error)

func (*Client) GetIPAssignments added in v0.1.67

func (f *Client) GetIPAssignments(ctx context.Context, appName string) (res *ListIPAssignmentsResponse, err error)

func (*Client) GetMany

func (f *Client) GetMany(ctx context.Context, appName string, machineIDs []string) ([]*fly.Machine, error)

func (*Client) GetMetadata

func (f *Client) GetMetadata(ctx context.Context, appName, machineID string) (map[string]string, error)

func (*Client) GetPlacements added in v0.1.47

func (f *Client) GetPlacements(ctx context.Context, request *GetPlacementsRequest) ([]RegionPlacement, error)

func (*Client) GetProcesses

func (f *Client) GetProcesses(ctx context.Context, appName, machineID string) (fly.MachinePsResponse, error)

func (*Client) GetRegions added in v0.1.45

func (f *Client) GetRegions(ctx context.Context) (*RegionData, error)

func (*Client) GetSecretKey added in v0.1.46

func (f *Client) GetSecretKey(ctx context.Context, appName, name string, version *uint64) (*fly.SecretKey, error)

func (*Client) GetVolume

func (f *Client) GetVolume(ctx context.Context, appName, volumeId string) (*fly.Volume, error)

func (*Client) GetVolumeSnapshots

func (f *Client) GetVolumeSnapshots(ctx context.Context, appName, volumeId string) ([]fly.VolumeSnapshot, error)

func (*Client) GetVolumes

func (f *Client) GetVolumes(ctx context.Context, appName string) ([]fly.Volume, error)

func (*Client) Kill

func (f *Client) Kill(ctx context.Context, appName, machineID string) (err error)

func (*Client) Launch

func (f *Client) Launch(ctx context.Context, appName string, builder fly.LaunchMachineInput) (out *fly.Machine, err error)

func (*Client) List

func (f *Client) List(ctx context.Context, appName, state string) ([]*fly.Machine, error)

func (*Client) ListActive

func (f *Client) ListActive(ctx context.Context, appName string) ([]*fly.Machine, error)

ListActive returns only non-destroyed that aren't in a reserved process group.

func (*Client) ListAppSecrets added in v0.1.46

func (f *Client) ListAppSecrets(ctx context.Context, appName string, version *uint64, showSecrets bool) ([]fly.AppSecret, error)

func (*Client) ListApps added in v0.1.67

func (f *Client) ListApps(ctx context.Context, req ListAppsRequest) (apps []App, err error)

func (*Client) ListFlyAppsMachines

func (f *Client) ListFlyAppsMachines(ctx context.Context, appName string) ([]*fly.Machine, *fly.Machine, error)

ListFlyAppsMachines returns apps that are part of Fly Launch. Destroyed machines and console machines are excluded. Unlike other List functions, this function retries multiple times.

func (*Client) ListSecretKeys added in v0.1.46

func (f *Client) ListSecretKeys(ctx context.Context, appName string, version *uint64) ([]fly.SecretKey, error)

func (*Client) NewRequest

func (f *Client) NewRequest(ctx context.Context, method, path string, in interface{}, headers map[string][]string) (*http.Request, error)

func (*Client) RefreshLease

func (f *Client) RefreshLease(ctx context.Context, appName, machineID string, ttl *int, nonce string) (*fly.MachineLease, error)

func (*Client) ReleaseLease

func (f *Client) ReleaseLease(ctx context.Context, appName, machineID, nonce string) error

func (*Client) Restart

func (f *Client) Restart(ctx context.Context, appName string, in fly.RestartMachineInput, nonce string) (err error)

func (*Client) SetAppSecret added in v0.1.46

func (f *Client) SetAppSecret(ctx context.Context, appName, name string, value string) (*fly.SetAppSecretResp, error)

func (*Client) SetMetadata

func (f *Client) SetMetadata(ctx context.Context, appName, machineID, key, value string) error

func (*Client) SetSecretKey added in v0.1.46

func (f *Client) SetSecretKey(ctx context.Context, appName, name string, typ string, value []byte) (*fly.SetSecretKeyResp, error)

func (*Client) SignSecretKey added in v0.1.46

func (f *Client) SignSecretKey(ctx context.Context, appName, name string, plaintext []byte, version *uint64) (*fly.SignSecretKeyResp, error)

func (*Client) Start

func (f *Client) Start(ctx context.Context, appName, machineID string, nonce string) (out *fly.MachineStartResponse, err error)

func (*Client) Stop

func (f *Client) Stop(ctx context.Context, appName string, in fly.StopMachineInput, nonce string) (err error)

func (*Client) Suspend added in v0.1.17

func (f *Client) Suspend(ctx context.Context, appName, machineID, nonce string) error

func (*Client) Uncordon

func (f *Client) Uncordon(ctx context.Context, appName, machineID string, nonce string) (err error)

func (*Client) Update

func (f *Client) Update(ctx context.Context, appName string, builder fly.LaunchMachineInput, nonce string) (out *fly.Machine, err error)

func (*Client) UpdateAppSecrets added in v0.1.51

func (f *Client) UpdateAppSecrets(ctx context.Context, appName string, values map[string]*string) (*fly.UpdateAppSecretsResp, error)

UpdateAppSecrets can set and delete secrets. Nil secret values are deleted, while others are set.

func (*Client) UpdateVolume

func (f *Client) UpdateVolume(ctx context.Context, appName, volumeId string, req fly.UpdateVolumeRequest) (*fly.Volume, error)

func (*Client) VerifySecretKey added in v0.1.46

func (f *Client) VerifySecretKey(ctx context.Context, appName, name string, plaintext, sig []byte, version *uint64) error

func (*Client) Wait

func (f *Client) Wait(ctx context.Context, appName string, machine *fly.Machine, state string, timeout time.Duration) (err error)

func (*Client) WaitForApp

func (f *Client) WaitForApp(ctx context.Context, name string) error

type CreateAppRequest added in v0.1.67

type CreateAppRequest struct {
	Name      string `json:"name"`
	Org       string `json:"org_slug"`
	Network   string `json:"network"`
	AppRoleID string `json:"app_role_id"`
}

type ErrorRequestID

type ErrorRequestID interface {
	ErrRequestID() string
}

TODO: we might not actually need an interface type here

type ErrorStatusCode

type ErrorStatusCode interface {
	error
	StatusCode() *StatusCode
}

type ErrorTraceID added in v0.1.5

type ErrorTraceID interface {
	ErrTraceID() string
}

type ExtendVolumeRequest

type ExtendVolumeRequest struct {
	SizeGB int `json:"size_gb"`
}

type ExtendVolumeResponse

type ExtendVolumeResponse struct {
	Volume       *fly.Volume `json:"volume"`
	NeedsRestart bool        `json:"needs_restart"`
}

type FlapsError

type FlapsError struct {
	OriginalError      error
	ResponseStatusCode int
	ResponseBody       []byte
	FlyRequestId       string
	TraceID            string
}

func (*FlapsError) ErrRequestID

func (fe *FlapsError) ErrRequestID() string

func (*FlapsError) ErrTraceID added in v0.1.5

func (fe *FlapsError) ErrTraceID() string

func (*FlapsError) Error

func (fe *FlapsError) Error() string

func (*FlapsError) Is

func (fe *FlapsError) Is(target error) bool

func (*FlapsError) ResponseBodyString

func (fe *FlapsError) ResponseBodyString() string

func (*FlapsError) StatusCode

func (fe *FlapsError) StatusCode() *StatusCode

func (*FlapsError) Suggestion

func (fe *FlapsError) Suggestion() string

func (*FlapsError) Unwrap

func (fe *FlapsError) Unwrap() error

type GetPlacementsRequest added in v0.1.47

type GetPlacementsRequest struct {
	// Resource requirements for the Machine to simulate. Defaults to a performance-1x machine
	ComputeRequirements *fly.MachineGuest `json:"compute"`

	// Region expression for placement as a comma-delimited set of regions or aliases.
	// Defaults to "[region],any", to prefer the API endpoint's local region with any other region as fallback.
	Region string `json:"region"`

	// Number of machines to simulate placement.
	// Defaults to 0, which returns the org-specific limit for each region.
	Count uint64 `json:"count"`

	VolumeName      string `json:"volume_name"`
	VolumeSizeBytes uint64 `json:"volume_size_bytes"`

	// Optional weights to override default placement preferences.
	Weights *Weights `json:"weights"`

	Org string `json:"org_slug"`
}

type GetPlacementsResponse added in v0.1.47

type GetPlacementsResponse struct {
	Regions []RegionPlacement
}

type IPAssignment added in v0.1.67

type IPAssignment struct {
	IP          string    `json:"ip"`
	Region      string    `json:"region"`
	ServiceName string    `json:"service_name"`
	Shared      bool      `json:"shared"`
	CreatedAt   time.Time `json:"created_at"`
}

func (IPAssignment) IsFlycast added in v0.1.67

func (ip IPAssignment) IsFlycast() bool

type ListAppsRequest added in v0.1.69

type ListAppsRequest struct {
	OrgSlug string
	// AppRole is optional
	AppRole string
}

type ListIPAssignmentsResponse added in v0.1.67

type ListIPAssignmentsResponse struct {
	IPs []IPAssignment `json:"ips"`
}

type NewClientOpts

type NewClientOpts struct {
	// optional, sent with requests
	UserAgent string

	Tokens *tokens.Tokens

	// optional:
	Logger fly.Logger

	// optional, used to construct the underlying HTTP client
	Transport http.RoundTripper
}

type RegionData added in v0.1.67

type RegionData struct {
	Regions []fly.Region `json:"Regions"`
	Nearest string       `json:"Nearest"`
}

type RegionPlacement added in v0.1.47

type RegionPlacement struct {
	Region      string
	Count       int
	Concurrency int
}

type StatusCode

type StatusCode string

func GetErrorStatusCode

func GetErrorStatusCode(err error) *StatusCode

type Weights added in v0.1.47

type Weights map[string]int64

Weights override default placement preferences. `region` (default 50) prefers regions closer to the target region. `spread` (default 1) prefers spreading placements across different hosts instead of packed on the same host.

Jump to

Keyboard shortcuts

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