Versions in this module Expand all Collapse all v0 v0.1.0 Oct 12, 2026 Changes in this version + const CodeAuthExpired + const CodeBadRequest + const CodeCanceled + const CodeConflict + const CodeForbidden + const CodeInternal + const CodeNotFound + const CodeOverloaded + const CodeRateLimited + const CodeResultTooLarge + const CodeTimeout + const CodeUnauthenticated + const CodeUnavailable + const CodeValidation + const MetricCoalescing + const MetricFenceLag + const MetricFenceWait + const MetricListenReconnect + const MetricObservers + const MetricPubRun + const MetricQueuedBytes + const MetricSlowClose + const MetricSubscriptions + const MetricTick + const MetricTickRuns + const Subprotocol + var ErrEventTooLarge = errors.New("cometgo: event too large") + var ErrForbidden = NewError(CodeForbidden, "forbidden") + var ErrUserIDTooLong = errors.New("cometgo: revalidate: user ID too long") + func InstallIdempotency(ctx context.Context, db *pgxpool.Pool) error + func InstallTriggers(ctx context.Context, db *pgxpool.Pool, tables ...string) error + func Method[A, R any](a *App, name string, fn func(c *Call, args A) (R, error)) + func Publish[A any](a *App, name string, opts PubOptions, ...) + type App struct + func New(cfg Config) *App + func (a *App) Emit(ctx context.Context, pubName string, args any, scope, topic string, data any) error + func (a *App) Revalidate(ctx context.Context, userID string) error + func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (a *App) Shutdown(ctx context.Context) error + func (a *App) Start(ctx context.Context) error + type Call struct + Context context.Context + Identity *Identity + Tx pgx.Tx + func (c *Call) EmitAfterCommit(pubName string, args any, scope, topic string, data any) error + func (c *Call) RevalidateAfterCommit(userID string) error + type ColSchema struct + Code string + Enum []string + Name string + Nullable bool + type Config struct + Authenticate func(ctx context.Context, token string) (*Identity, error) + AuthenticateRequest func(r *http.Request) (*Identity, error) + Build string + ClientIP func(r *http.Request) string + DB *pgxpool.Pool + FenceTimeout time.Duration + Heartbeat time.Duration + IdempotencyTTL time.Duration + Logger *slog.Logger + MaxConns int + MaxConnsPerIP int + MaxInflight int + MaxMsg int + MaxObservers int + MaxRows int + MaxSubs int + Metrics func(Metric) + MinTickInterval time.Duration + OriginPatterns []string + QueryTimeout time.Duration + ResumeBuffer int + ResumeGrace time.Duration + type DescribeOptions struct + Identity *Identity + type Error struct + Code string + Details any + Msg string + RetryAfterMs int64 + func NewError(code, msg string) *Error + func ValidationError(fields map[string]string) *Error + func (e *Error) Error() string + type Identity struct + Data any + ExpiresAt time.Time + ScopeKey string + User any + UserID string + func (id *Identity) Scope() string + type MethodSchema struct + Args string + Name string + Result string + type Metric struct + Name string + Pub string + Value float64 + type PubOptions struct + Events bool + Key []string + Row any + Scope Scope + Tables []string + Unordered bool + type PubSchema struct + Args string + Cols []ColSchema + Name string + type Query struct + Args []any + Match map[string]any + SQL string + type Schema struct + Methods []MethodSchema + Publications []PubSchema + func Describe(ctx context.Context, a *App, opts DescribeOptions) (*Schema, error) + func (s *Schema) TypeScript() []byte + type Scope int + const ScopeShared + const ScopeUser + type SubCtx struct + Context context.Context + Identity *Identity