orchestrator

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 48 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFixedAlreadyCharged = errors.New("fixed-price session already charged")
View Source
var ErrInsufficientBalance = errors.New("insufficient payment balance")
View Source
var ErrInvalidPayment = errors.New("invalid payment")
View Source
var ErrMissingChallenge = errors.New("payment challenge not found")

Functions

func ManifestFromSegment

func ManifestFromSegment(header string) (string, error)

func Root

func Root(out, errOut io.Writer) *cobra.Command

func Serve

func Serve(parent context.Context, p Params, logOut io.Writer) (result error)

Types

type Challenge

type Challenge struct {
	PaymentParams string `json:"payment_params"`
	Orchestrator  string `json:"orchestrator"`
	ManifestID    string `json:"manifest_id"`
	PaymentURL    string `json:"payment_url"`
}

type Params

type Params struct {
	ConfigFile string `` /* 151-byte string literal not displayed */
	nodeconfig.Settings
	Account                   *ethcommon.Address `descr:"Keystore account address"`
	OrchestratorAddress       *ethcommon.Address `descr:"Registered orchestrator address receiving ticket payments; defaults to the keystore account"`
	ETHUSDFeed                *ethcommon.Address `name:"eth-usd-feed" descr:"ETH/USD oracle address, alternative to a fixed wei-per-usd rate"`
	PriceMaxAge               time.Duration      `default:"2h" descr:"Maximum age of the oracle observation"`
	Listen                    boa.HTTPBind       `default:"127.0.0.1:8935" descr:"Public HTTP listener"`
	MetricsListen             boa.HTTPBind       `default:"127.0.0.1:8936" descr:"Metrics listener"`
	ServiceURL                boa.Text[*url.URL] `optional:"true" descr:"Public orchestrator base URL; defaults to http://listen"`
	APIOriginURL              boa.Text[*url.URL] `optional:"true" descr:"Client API Host as a URL; defaults to service-url"`
	RunnerServiceURL          boa.Text[*url.URL] `optional:"true" descr:"Runner-facing base URL for callbacks and trickle; defaults to service-url"`
	ProxyURLTemplate          string             `optional:"true" descr:"Generated proxy URL with {proxy} in a hostname label or final path segment"`
	ExcludedHeaders           []string           `optional:"true" descr:"Headers to remove from app requests; a trailing * matches a prefix"`
	ExcludedCookies           []string           `optional:"true" descr:"Cookie names to remove from app requests; matching is case-sensitive"`
	BootstrapSecret           string             `secret:"true" optional:"true" descr:"Dynamic runner bootstrap credential"`
	BootstrapSecretFile       string             `basepath:"source" secretfor:"BootstrapSecret" descr:"File containing runner bootstrap credential"`
	RunnerConfig              string             `basepath:"source" optional:"true" file:"true" descr:"Static runner TOML path"`
	RedeemerURL               *url.URL           `name:"redeemer-url" optional:"true" descr:"Remote winning-ticket redeemer base URL"`
	RedeemerHeaders           nodeconfig.Headers `optional:"true" secret:"true" descr:"Headers authenticating winning-ticket submission"`
	RedeemerHeadersFile       string             `basepath:"source" secretfor:"RedeemerHeaders" descr:"Owner-only ticket submission headers file"`
	RedeemerGrants            []string           `optional:"true" descr:"Private remote redeemer IP[:port] or CIDR grants"`
	MaxPendingTickets         int                `default:"100000" min:"1" descr:"Maximum unsettled winning tickets"`
	MaxTicketsPerRecipient    int                `default:"10000" min:"1" descr:"Maximum unsettled tickets per recipient"`
	RedeemerDB                string             `optional:"true" file:"optional"`
	KeystoreFile              string             `basepath:"source" optional:"true" descr:"Encrypted geth redemption account JSON file"`
	KeystorePassword          *string            `secret:"true" optional:"true" descr:"Keystore decryption password"`
	KeystorePasswordFile      string             `basepath:"source" secretfor:"KeystorePassword" descr:"Owner-only file containing the exact keystore password bytes"`
	RPCURL                    *url.URL           `name:"rpc-url" secret:"true" optional:"true"`
	RPCURLFile                string             `basepath:"source" name:"rpc-url-file" secretfor:"RPCURL"`
	ChainID                   *uint64            `min:"1"`
	RedeemerTxTimeout         time.Duration      `default:"5m" descr:"Inclusion timeout for each redemption transaction attempt"`
	RedeemerMaxTxReplacements int                `default:"1" min:"0" descr:"Maximum fee replacements per redemption attempt"`
	RedeemerMaxFeePerGas      *uint256.Int       `descr:"Optional maximum redemption fee in wei per gas"`
	Controller                *ethcommon.Address `name:"controller-address"`
	WeiPerUSD                 *big.Rat
	TicketFaceValue           *uint256.Int
	TicketWinProb             *uint256.Int
	RunnerGrants              []string      `optional:"true" descr:"Private runner IP[:port] or CIDR grants"`
	SessionProxyGrants        []string      `optional:"true" descr:"Private session proxy IP[:port] or CIDR grants"`
	HealthGrants              []string      `optional:"true" descr:"Private static runner health IP[:port] or CIDR grants"`
	HeartbeatInterval         time.Duration `default:"5s" descr:"Runner heartbeat interval"`
	HeartbeatTTL              time.Duration `default:"30s" descr:"Runner heartbeat expiry"`
	DrainTimeout              time.Duration `default:"12h" descr:"Maximum app drain time after withdrawal, from 0 to 12h; zero ends work immediately"`
	SessionIdleTimeout        time.Duration `default:"30s" descr:"Idle time before releasing a persistent session (0 disables expiry)"`
	PrintConfig               bool          `optional:"true" boa:"noconfig,noenv" descr:"Print audited redacted TOML configuration"`
}

func (Params) Validate

func (p Params) Validate() error

type PaymentEngine

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

PaymentEngine owns process-local payment challenges and session accounting. Winning tickets and redemption state are durable in the orchestrator redeemer.

func NewPaymentEngine

func NewPaymentEngine(store *RedeemerDB, chain pm.PaymentChain, recipient ethcommon.Address, faceValue, winProb *big.Int) (*PaymentEngine, error)

func (*PaymentEngine) Balance

func (e *PaymentEngine) Balance(manifest string) (*big.Rat, error)

func (*PaymentEngine) ChallengeForManifest

func (e *PaymentEngine) ChallengeForManifest(appID, manifest, service string) (Challenge, error)

func (*PaymentEngine) ChallengeInfo

func (e *PaymentEngine) ChallengeInfo(manifest string) (wire.OrchestratorInfo, error)

func (*PaymentEngine) ChallengePrice

func (e *PaymentEngine) ChallengePrice(appID, manifest string) (int64, string, error)

ChallengePrice returns the agreed quote for a pending reservation, scoped to its app registration. App and feed updates must not change a previously issued quote.

func (*PaymentEngine) Charge

func (e *PaymentEngine) Charge(ctx context.Context, manifest string, now time.Time) (result error)

func (*PaymentEngine) MakeChallenge

func (e *PaymentEngine) MakeChallenge(ctx context.Context, appID, manifest string, payer ethcommon.Address, price int64, unit, service string) (challenge Challenge, result error)

MakeChallenge returns a Python/Go runner compatible 402 body. Ticket parameters are authenticated by the recipient HMAC.

func (*PaymentEngine) PruneControlState

func (e *PaymentEngine) PruneControlState(ctx context.Context) error

PruneControlState bounds process-local session and nonce state. Winning tickets and uncertain broadcasts remain durable for redemption/recovery.

func (*PaymentEngine) Receive

func (e *PaymentEngine) Receive(ctx context.Context, appID, manifest, paymentHeader, segmentHeader string) (payerResult ethcommon.Address, credit *big.Rat, result error)

func (*PaymentEngine) RefreshChallenge

func (e *PaymentEngine) RefreshChallenge(ctx context.Context, manifest string, payer ethcommon.Address, service string) (challenge Challenge, result error)

type RedeemerDB

type RedeemerDB struct {
	*redemption.RedeemerDB
	// contains filtered or unexported fields
}

RedeemerDB keeps the payment admission adapter alongside the shared queue.

func OpenRedeemerDB

func OpenRedeemerDB(path string) (*RedeemerDB, error)

type Registry

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

func NewRegistry

func NewRegistry(secret, service string, interval, ttl time.Duration) *Registry

func (*Registry) AddStatic

func (r *Registry) AddStatic(config StaticRunner) error

func (*Registry) CheckStaticHealth

func (r *Registry) CheckStaticHealth(ctx context.Context, client *http.Client)

func (*Registry) Close

func (r *Registry) Close()

func (*Registry) Counts

func (r *Registry) Counts() (runners, sessions int)

func (*Registry) Discovery

func (r *Registry) Discovery() []discoveryEntry

func (*Registry) Expire

func (r *Registry) Expire()

func (*Registry) Heartbeat

func (r *Registry) Heartbeat(req heartbeatRequest, auth string) (heartbeatResponse, int, error)

func (*Registry) ModeForRunner

func (r *Registry) ModeForRunner(id string) (string, int, error)

func (*Registry) PaidSessions

func (r *Registry) PaidSessions() []string

func (*Registry) PriceForRunner

func (r *Registry) PriceForRunner(id string) (priceInfo, int, error)

PriceForRunner returns the price for an app registration ID (a runner ID for legacy apps).

func (*Registry) PriceForSession

func (r *Registry) PriceForSession(id, sid string) (priceInfo, int, error)

func (*Registry) ReleaseBySession

func (r *Registry) ReleaseBySession(sid string, reasons ...string)

func (*Registry) Reserve

func (r *Registry) Reserve(id string) (string, string, string, int, error)

func (*Registry) ReserveWithID

func (r *Registry) ReserveWithID(id, requestedID string) (string, string, string, int, error)

func (*Registry) SetWeiPerUSD

func (r *Registry) SetWeiPerUSD(rate *big.Rat)

func (*Registry) String

func (r *Registry) String() string

func (*Registry) Unregister

func (r *Registry) Unregister(id, auth string) (int, error)

type Server

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

func NewServer

func NewServer(registry *Registry, runnerPolicy, proxyPolicy destination.Policy, logger *slog.Logger) *Server

func (*Server) ChargePaidSessions

func (s *Server) ChargePaidSessions(ctx context.Context)

func (*Server) Close

func (s *Server) Close()

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetPayment

func (s *Server) SetPayment(engine *PaymentEngine)

func (*Server) String

func (s *Server) String() string

type StaticRunner

type StaticRunner struct {
	ID         string
	Proxy      bool
	RunnerURL  string
	Version    string
	Metadata   string
	GPU        *runnerGPU
	App        string
	Mode       string
	Status     string
	Capacity   int
	HealthURL  string
	HealthCode int
	PriceInfo  priceInfo
}

Jump to

Keyboard shortcuts

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