machine

package
v0.0.0-...-ab2e974 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Define a shorter duration for when no machines are available
	FAST_POLL_DURATION = 30 * time.Second
)

Variables

View Source
var (
	UserMachines = make(map[string][]string)
	UserChecks   = make(map[string]time.Time)
)
View Source
var (
	MachineMap = make(map[string]*Machine)
)

Functions

func CheckAll

func CheckAll(ctx context.Context)

CheckAll runs checkStatus on all machines

func FetchMachines

func FetchMachines(ctx context.Context) error

fetch updated machine list if not MACHINE_CACHE_DURATION

func HandleMachineCheck

func HandleMachineCheck(w http.ResponseWriter, r *http.Request)

Handler for the /machines endpoint

func RegisterRouter

func RegisterRouter(ctx context.Context)

RegisterRouter creates the generation queue

Types

type EndpointState

type EndpointState int
const (
	// Machine is ready to accept new generations
	Ready EndpointState = iota
	// Machine is currently generating an image
	Generating
	// Machine is either downloading or updating the model
	Preparing
	// Machine failed to generate an image or is past max check interval
	Failed
	// Machine state has not been set yet
	Unknown
)

Enumeration of endpoint states

func (EndpointState) MarshalJSON

func (d EndpointState) MarshalJSON() ([]byte, error)

func (EndpointState) String

func (d EndpointState) String() string

type GenerationMessage

type GenerationMessage struct {
	Machine *Machine `json:"machine"`
	Message []byte   `json:"message"`
	Type    string   `json:"type" validate:"oneof=completed failed progress state"`
}

type GetMachinesResponse

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

func GetMachineList

func GetMachineList(ctx context.Context, input *MachineRequest) (*GetMachinesResponse, error)

type ImageModels

type ImageModels struct {
	Checkpoint   VersionReference   `json:"checkpoint" validate:"required"`
	HrCheckpoint *VersionReference  `json:"hr_checkpoint"`
	HrLoras      []VersionReference `json:"hr_loras"`
	Loras        []VersionReference `json:"loras"`
	Embeddings   []VersionReference `json:"embeddings"`
	ControlNets  []VersionReference `json:"controlnets"`
}

type Machine

type Machine struct {
	MachineResponse

	Progress    float32                        `json:"progress"`
	EtaRelative float32                        `json:"eta"`
	Generation  *generator.ImageDetailResponse `json:"generation"`
	State       EndpointState                  `json:"state"`
	LastRequest time.Time
	Failures    int
	// contains filtered or unexported fields
}

func FetchUserMachines

func FetchUserMachines(ctx context.Context, uid string) (machineList []*Machine, err error)

func (*Machine) GetBackoff

func (m *Machine) GetBackoff() time.Duration

func (*Machine) GetLogTags

func (m *Machine) GetLogTags() string

func (*Machine) LogWithTags

func (m *Machine) LogWithTags(ctx context.Context, msg ...string)

func (*Machine) PublishStatus

func (machine *Machine) PublishStatus(sendCtx context.Context) error

Machine publishes it's current state to the status exchange

func (*Machine) PublishUpdate

func (machine *Machine) PublishUpdate(sendCtx context.Context, msg []byte, kind string) error

TODO: combine with NotifyRequestor? Possibly write wrappers around different kinds to have better Message schemas. This is a bit of a mess. Not sure if it should be a method on machine or a seperate message struct with a method for publishing.

func (*Machine) URL

func (m *Machine) URL() string

type MachineRequest

type MachineRequest struct{}

type MachineResponse

type MachineResponse struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Endpoint    string    `json:"url"`
	OwnerID     string    `json:"owner_id"`
	IsPublic    bool      `json:"is_public"`
	Enabled     bool      `json:"enabled"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type QueuedGenerationRequest

type QueuedGenerationRequest struct {
	Image         QueuedImage         `json:"image"`
	ImageMetadata QueuedImageMetadata `json:"image_metadata"`
	Models        ImageModels         `json:"models"`
}

type QueuedImage

type QueuedImage struct {
	Id     string `json:"id"`
	UserId string `json:"user_id"`
	Status string `json:"status" validate:"oneof=Queued Generating Done Canceled Failed Deleted"`
}

type QueuedImageMetadata

type QueuedImageMetadata struct {
	Queued    string `json:"queued_at"`
	Started   string `json:"started_at"`
	Canceled  string `json:"canceled_at"`
	Completed string `json:"completed_at"`
	Failures  int    `json:"failures"`
}

type ReadinessResponse

type ReadinessResponse = struct {
	Progress    float32 `json:"progress"`
	EtaRelative float32 `json:"eta_relative"`
}

Sends information about the state of the machine to consumers

type VersionReference

type VersionReference struct {
	VersionId string `json:"model_id" validate:"required,uuid"`
}

Jump to

Keyboard shortcuts

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