Documentation
¶
Index ¶
- Constants
- type Auth
- type AuthCtx
- type Engine
- func (e *Engine) CreateTable(name string, schema interface{})
- func (e *Engine) ExecuteMutation(mutation string, params map[string]interface{}, clientID string, ...) (interface{}, error)
- func (e *Engine) ExecuteMutationInternal(mutation string, params map[string]interface{}) (interface{}, error)
- func (e *Engine) ExecuteQuery(query string, params map[string]interface{}, ...) ([]byte, error)
- func (e *Engine) GetDependentQueries(tableName string) []string
- func (e *Engine) Handle(w http.ResponseWriter, r *http.Request)
- func (e *Engine) InvalidateTag(tag string)
- func (e *Engine) InvalidateTags(tags []string, execID string, actionName string)
- func (e *Engine) OnConnect(clientID string) error
- func (e *Engine) OnDisconnect(clientID string) error
- func (e *Engine) OnReceiveMessage(clientID string, msg map[string]interface{}) error
- func (e *Engine) RegisterCron(cronName string, cronString string, functionName string, ...) (string, error)
- func (e *Engine) RegisterGuard(name string, guard func(ctx *GuardCtx) interface{})
- func (e *Engine) RegisterMutation(name string, mutation func(ctx *MutationCtx) interface{}, ...)
- func (e *Engine) RegisterQuery(name string, query func(ctx *QueryCtx) interface{}, dependencies []string, ...)
- func (e *Engine) SetAllowedOrigins(allowedOrigins []string)
- func (e *Engine) SetAuth(auth Auth)
- func (e *Engine) SetCheckOrigin(checkOrigin func(r *http.Request) bool)
- func (e *Engine) StorageHandler(w http.ResponseWriter, r *http.Request)
- func (e *Engine) UseStorage(storage storage.StorageAdapter)
- type Guard
- type GuardCtx
- type Mutation
- type MutationCtx
- type MutationOptions
- type Query
- type QueryCtx
- type QueryOptions
- type SchedulerCtx
- type StorageCtx
- type TetherDownloadToken
- type TetherStorage
- type TetherTask
Constants ¶
const ( ContextKeyExecutionID traceContextKey = "exec_id" ContextKeyActionName traceContextKey = "action_name" )
const SCHEDULE_LOOKAHEAD = 15 * time.Second
const SCHEDULE_LOOP_INTERVAL = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
Profiler *utilities.Profiler
EphemeralID string
// contains filtered or unexported fields
}
func (*Engine) CreateTable ¶
func (*Engine) ExecuteMutation ¶
func (*Engine) ExecuteMutationInternal ¶ added in v0.3.0
func (*Engine) ExecuteQuery ¶
func (e *Engine) ExecuteQuery(query string, params map[string]interface{}, subscription *reactivity.Subscription, forceSend bool) ([]byte, error)
func (*Engine) GetDependentQueries ¶
func (*Engine) InvalidateTag ¶
func (*Engine) InvalidateTags ¶ added in v0.2.0
InvalidateTags re-runs each distinct subscription that listens to any of the given tags. Subscriptions are snapshotted before any query executes so a re-run that picks up additional tags (e.g. auto-tracked primary keys) cannot cause the same mutation to fire the query a second time. Matching subscriptions (same query, params, and auth fingerprint) share one execution and are fanned out with each client's own query_key.
func (*Engine) OnDisconnect ¶
func (*Engine) OnReceiveMessage ¶
func (*Engine) RegisterCron ¶ added in v0.5.0
func (*Engine) RegisterGuard ¶ added in v0.4.0
func (*Engine) RegisterMutation ¶
func (e *Engine) RegisterMutation(name string, mutation func(ctx *MutationCtx) interface{}, opts ...MutationOptions)
func (*Engine) RegisterQuery ¶
func (e *Engine) RegisterQuery(name string, query func(ctx *QueryCtx) interface{}, dependencies []string, opts ...QueryOptions)
func (*Engine) SetAllowedOrigins ¶
SetAllowedOrigins allows the listed origins for WebSocket upgrades and storage routes. Browsers calling those storage routes from an allowed origin receive the CORS headers the request needs.
func (*Engine) SetCheckOrigin ¶
SetCheckOrigin sets the function that accepts or rejects browser origins. It applies to WebSocket upgrades and to storage routes served by the engine.
func (*Engine) StorageHandler ¶ added in v0.7.0
func (e *Engine) StorageHandler(w http.ResponseWriter, r *http.Request)
func (*Engine) UseStorage ¶ added in v0.7.0
func (e *Engine) UseStorage(storage storage.StorageAdapter)
type GuardCtx ¶ added in v0.4.0
type GuardCtx struct {
DB *gorm.DB
Auth *AuthCtx
Params map[string]interface{}
Profiler *utilities.Profiler
Dependencies []string
}
func (*GuardCtx) TrackCollection ¶ added in v0.4.0
func (*GuardCtx) TrackTable ¶ added in v0.4.0
type Mutation ¶ added in v0.3.0
type Mutation struct {
Func func(ctx *MutationCtx) interface{}
Internal bool
}
type MutationCtx ¶
type MutationCtx struct {
DB *gorm.DB
Auth *AuthCtx
Scheduler *SchedulerCtx
Params map[string]interface{}
Profiler *utilities.Profiler
Storage *StorageCtx
}
type MutationOptions ¶ added in v0.3.0
type MutationOptions struct {
Internal bool
}
type QueryCtx ¶
type QueryCtx struct {
DB *gorm.DB
Auth *AuthCtx
Scheduler *SchedulerCtx
Params map[string]interface{}
Dependencies []string
Storage *StorageCtx
}
func (*QueryCtx) TrackCollection ¶
func (*QueryCtx) TrackTable ¶
type QueryOptions ¶ added in v0.3.0
type QueryOptions struct {
Internal bool
}
type SchedulerCtx ¶ added in v0.5.0
type StorageCtx ¶ added in v0.7.0
type StorageCtx struct {
GetUploadURL func(opts storage.UploadOptions) (storage.UploadInfo, error)
GetDownloadURL func(fileID string) (string, error)
DeleteFile func(fileID string) error
}
type TetherDownloadToken ¶ added in v0.7.0
type TetherStorage ¶ added in v0.7.0
type TetherStorage struct {
ID string `gorm:"primaryKey"` // file ID
Token string `gorm:"uniqueIndex"` // token used to upload the file
Status string `gorm:"index"` // status of the upload (pending, completed, failed)
FileSize int64
MaxBytes int64 // maximum size allowed at upload time
MimeType string // MIME type of the file
ExpiresAt time.Time // time when the upload token expires
CreatedAt time.Time // time when the upload token was created
}
type TetherTask ¶ added in v0.5.0
type TetherTask struct {
ID string `gorm:"primaryKey"`
Name string `gorm:"uniqueIndex:idx_tether_cron_name,where:is_cron = true"` // unique among crons; one-shot tasks leave this empty
FunctionName string `gorm:"not null"`
ParamsJSON string
ExecuteAt time.Time `gorm:"index"`
ClaimedBy *string `gorm:"index"`
LockedUntil *time.Time
// Cron specific (Can be empty for runAfter tasks)
CronString *string // e.g., "0 16 1 * *"
LastExecuted *time.Time
IsCron bool
}