Documentation
¶
Index ¶
- func BuildEnvFromDB(opts BuildEnvOptions, siteID string, assets worker.AssetsFetcher) *worker.Env
- func DeleteFile(path string) error
- func GetD1Path(dataDir, databaseID string) string
- func GetDataDir() string
- type BuildEnvOptions
- type CronRunner
- type GORMCacheStore
- type GORMDurableObjectStore
- func (b *GORMDurableObjectStore) Delete(namespace, objectID, key string) error
- func (b *GORMDurableObjectStore) DeleteAll(namespace, objectID string) error
- func (b *GORMDurableObjectStore) DeleteMulti(namespace, objectID string, keys []string) (int, error)
- func (b *GORMDurableObjectStore) Get(namespace, objectID, key string) (string, error)
- func (b *GORMDurableObjectStore) GetMulti(namespace, objectID string, keys []string) (map[string]string, error)
- func (b *GORMDurableObjectStore) List(namespace, objectID, prefix string, limit int, reverse bool) ([]worker.KVPair, error)
- func (b *GORMDurableObjectStore) Put(namespace, objectID, key, valueJSON string) error
- func (b *GORMDurableObjectStore) PutMulti(namespace, objectID string, entries map[string]string) error
- type GORMKVStore
- func (kv *GORMKVStore) Delete(key string) error
- func (kv *GORMKVStore) Get(key string) (string, error)
- func (kv *GORMKVStore) GetWithMetadata(key string) (*worker.KVValueWithMetadata, error)
- func (kv *GORMKVStore) List(prefix string, limit int, cursor string) (*worker.KVListResult, error)
- func (kv *GORMKVStore) Put(key, value string, metadata *string, ttl *int) error
- type GORMQueueConsumer
- type GORMQueueSender
- type LogRetentionRunner
- type MinioR2Store
- func (s *MinioR2Store) Delete(keys []string) error
- func (s *MinioR2Store) Get(key string) ([]byte, *worker.R2Object, error)
- func (s *MinioR2Store) Head(key string) (*worker.R2Object, error)
- func (s *MinioR2Store) List(opts worker.R2ListOptions) (*worker.R2ListResult, error)
- func (s *MinioR2Store) PresignedGetURL(key string, expiry time.Duration) (string, error)
- func (s *MinioR2Store) PublicURL(key string) (string, error)
- func (s *MinioR2Store) Put(key string, data []byte, opts worker.R2PutOptions) (*worker.R2Object, error)
- type PlatformDispatcher
- type QueueMessage
- type StaticAssetsFetcher
- type StorageSourceLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEnvFromDB ¶
func BuildEnvFromDB(opts BuildEnvOptions, siteID string, assets worker.AssetsFetcher) *worker.Env
BuildEnvFromDB loads environment variables, secrets, and all bindings for a site from the database, returning a worker.Env ready for execution.
func GetDataDir ¶
func GetDataDir() string
GetDataDir returns the data directory from the environment or a default.
Types ¶
type BuildEnvOptions ¶
type BuildEnvOptions struct {
DB *gorm.DB
MinioClient *minio.Client
PresignClient *minio.Client
PublicS3URL string
D1DataDir string
Dispatcher worker.WorkerDispatcher
Store *storage.Manager
Cache *storage.SiteRulesCache
}
BuildEnvOptions holds the dependencies needed to build a worker Env from the database.
type CronRunner ¶
type CronRunner struct {
// contains filtered or unexported fields
}
CronRunner ticks every minute, evaluates schedules, and dispatches worker scheduled() handlers for matching cron entries.
func NewCronRunner ¶
func NewCronRunner(db *gorm.DB, engine *worker.Engine, envFactory func(string) *worker.Env) *CronRunner
NewCronRunner creates and starts a CronRunner that evaluates schedules every minute. Call Shutdown() to stop it.
func (*CronRunner) Shutdown ¶
func (cr *CronRunner) Shutdown()
Shutdown stops the cron runner and waits for it to finish.
type GORMCacheStore ¶
GORMCacheStore implements worker.CacheStore using GORM.
func (*GORMCacheStore) Delete ¶
func (cs *GORMCacheStore) Delete(cacheName, url string) (bool, error)
Delete removes a cached response. Returns true if an entry was deleted.
func (*GORMCacheStore) Match ¶
func (cs *GORMCacheStore) Match(cacheName, url string) (*worker.CacheEntry, error)
Match retrieves a cached response for the given cache name and URL. Returns nil if not found or expired.
type GORMDurableObjectStore ¶
GORMDurableObjectStore implements worker.DurableObjectStore using GORM.
func (*GORMDurableObjectStore) Delete ¶
func (b *GORMDurableObjectStore) Delete(namespace, objectID, key string) error
Delete removes a single key.
func (*GORMDurableObjectStore) DeleteAll ¶
func (b *GORMDurableObjectStore) DeleteAll(namespace, objectID string) error
DeleteAll removes all entries for a given object.
func (*GORMDurableObjectStore) DeleteMulti ¶
func (b *GORMDurableObjectStore) DeleteMulti(namespace, objectID string, keys []string) (int, error)
DeleteMulti removes multiple keys, returning the count deleted.
func (*GORMDurableObjectStore) Get ¶
func (b *GORMDurableObjectStore) Get(namespace, objectID, key string) (string, error)
Get retrieves a single value by key, returning "" if not found.
func (*GORMDurableObjectStore) GetMulti ¶
func (b *GORMDurableObjectStore) GetMulti(namespace, objectID string, keys []string) (map[string]string, error)
GetMulti retrieves multiple values by keys.
func (*GORMDurableObjectStore) List ¶
func (b *GORMDurableObjectStore) List(namespace, objectID, prefix string, limit int, reverse bool) ([]worker.KVPair, error)
List returns entries matching an optional prefix, with limit and reverse support.
func (*GORMDurableObjectStore) Put ¶
func (b *GORMDurableObjectStore) Put(namespace, objectID, key, valueJSON string) error
Put upserts a single key-value pair.
type GORMKVStore ¶
GORMKVStore implements worker.KVStore using GORM.
func (*GORMKVStore) Delete ¶
func (kv *GORMKVStore) Delete(key string) error
Delete removes a key from the namespace.
func (*GORMKVStore) Get ¶
func (kv *GORMKVStore) Get(key string) (string, error)
Get retrieves a value by key, returning "" if not found or expired.
func (*GORMKVStore) GetWithMetadata ¶
func (kv *GORMKVStore) GetWithMetadata(key string) (*worker.KVValueWithMetadata, error)
GetWithMetadata retrieves a value and its metadata by key.
func (*GORMKVStore) List ¶
func (kv *GORMKVStore) List(prefix string, limit int, cursor string) (*worker.KVListResult, error)
List returns keys (and metadata) matching a prefix, up to limit entries, with cursor-based pagination support.
type GORMQueueConsumer ¶
GORMQueueConsumer provides server-side queue message consumption.
func (*GORMQueueConsumer) Ack ¶
func (qc *GORMQueueConsumer) Ack(messageID string) error
Ack marks a message as acknowledged.
func (*GORMQueueConsumer) Consume ¶
func (qc *GORMQueueConsumer) Consume(queueName string, batchSize int) ([]QueueMessage, error)
Consume retrieves up to batchSize unacked messages from the queue.
type GORMQueueSender ¶
GORMQueueSender implements worker.QueueSender using GORM.
func (*GORMQueueSender) Send ¶
func (qs *GORMQueueSender) Send(body, contentType string) (string, error)
Send creates a single message in the queue and returns its ID.
func (*GORMQueueSender) SendBatch ¶
func (qs *GORMQueueSender) SendBatch(messages []worker.QueueMessageInput) ([]string, error)
SendBatch creates multiple messages in the queue and returns their IDs.
type LogRetentionRunner ¶
type LogRetentionRunner struct {
// contains filtered or unexported fields
}
LogRetentionRunner periodically deletes old worker logs.
func NewLogRetentionRunner ¶
func NewLogRetentionRunner(db *gorm.DB, maxDays int) *LogRetentionRunner
NewLogRetentionRunner creates and starts a log retention runner that deletes worker logs older than maxDays. Ticks every hour.
func (*LogRetentionRunner) Stop ¶
func (lr *LogRetentionRunner) Stop()
Stop stops the log retention runner and waits for it to finish.
type MinioR2Store ¶
type MinioR2Store struct {
Client *minio.Client
PresignClient *minio.Client // optional client configured with public S3 host for presigning
BucketName string
PublicS3URL string // public-facing S3 URL for direct object URLs
}
MinioR2Store implements worker.R2Store using minio-go.
func (*MinioR2Store) Delete ¶
func (s *MinioR2Store) Delete(keys []string) error
Delete removes one or more objects by key.
func (*MinioR2Store) Head ¶
func (s *MinioR2Store) Head(key string) (*worker.R2Object, error)
Head retrieves object metadata without downloading the body.
func (*MinioR2Store) List ¶
func (s *MinioR2Store) List(opts worker.R2ListOptions) (*worker.R2ListResult, error)
List lists objects in the bucket with optional filtering.
func (*MinioR2Store) PresignedGetURL ¶
PresignedGetURL generates a pre-signed URL for downloading an object.
func (*MinioR2Store) PublicURL ¶
func (s *MinioR2Store) PublicURL(key string) (string, error)
PublicURL returns the public URL for an object.
func (*MinioR2Store) Put ¶
func (s *MinioR2Store) Put(key string, data []byte, opts worker.R2PutOptions) (*worker.R2Object, error)
Put stores an object and returns its metadata.
type PlatformDispatcher ¶
PlatformDispatcher implements worker.WorkerDispatcher by delegating to an Engine.
func (*PlatformDispatcher) Execute ¶
func (pd *PlatformDispatcher) Execute(siteID, deployKey string, env *worker.Env, req *worker.WorkerRequest) *worker.WorkerResult
Execute dispatches a worker request, optionally building the env from the factory.
type QueueMessage ¶
type QueueMessage struct {
ID string `gorm:"primaryKey"`
QueueName string `gorm:"index"`
Body string
ContentType string
CreatedAt time.Time
Acked bool `gorm:"default:false"`
SiteID string `gorm:"index"`
}
QueueMessage represents a message in a queue, stored in SQLite via GORM.
func (*QueueMessage) BeforeCreate ¶
func (q *QueueMessage) BeforeCreate(_ *gorm.DB) error
BeforeCreate generates an ID for QueueMessage if not set.
type StaticAssetsFetcher ¶
type StaticAssetsFetcher struct {
Store *storage.Manager
Cache *storage.SiteRulesCache
SiteID string
DeployKey string
SPAMode bool
Domain string
}
StaticAssetsFetcher implements worker.AssetsFetcher by replicating the static file serving pipeline (redirects, headers, rewrites, SPA fallback, 404).
func (*StaticAssetsFetcher) Fetch ¶
func (f *StaticAssetsFetcher) Fetch(req *worker.WorkerRequest) (*worker.WorkerResponse, error)
Fetch processes a WorkerRequest through the static pipeline and returns the appropriate response, just as the main server would.
type StorageSourceLoader ¶
StorageSourceLoader implements worker.SourceLoader using the storage manager.
func (*StorageSourceLoader) GetWorkerScript ¶
func (s *StorageSourceLoader) GetWorkerScript(siteID, deployKey string) (string, error)
GetWorkerScript retrieves the worker JS source for the given site and deploy key.