manager

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package manager — connectors_api_admin.go: JSON twins of the per-row admin controls that previously lived only on the form-post templ pages (rate limit, duplicate, access policy, session config, operation toggles, and account management). Each handler reuses the same service calls + permission gates as its templ sibling in connectors.go — the only difference is JSON in/out instead of form-post + redirect, so the manager SPA can drive them without a page reload.

Package manager — oauth.go: Generic connector OAuth 2.0 flow handler.

Purpose: Implements the two-leg OAuth 2.0 flow for any connector that has Module.OAuth set to a non-nil *connector.OAuthMeta. Routes are registered under /manager/connectors/{key}/oauth/* so the Redirect URI is always /manager/connectors/{key}/oauth/callback.

Caller: Handler.connectorRoutes() (public, not behind auth middleware) Dependencies: connector.OAuthMeta, configs.Service, connectors.Service Main Functions:

  • oauthRoutes() — registers start + callback routes (public)
  • oauthStart() — builds state, redirects to provider consent page
  • oauthCallback() — validates state, exchanges code, saves token
  • oauthSaveToken() — persists xoxp/access token to connector row
  • migrateOAuthAppToInstances() — one-shot boot migration: copies shared connector_oauth:{key} credentials into every instance row that has not yet been configured.

Storage:

  • Per-instance OAuth credentials: connector row configs (client_id, client_secret)
  • Legacy shared credentials: configs owner "connector_oauth:{key}" (migrated away)
  • Pending states: Handler.oauthPending (sync.Map, 10-min TTL)

Side Effects: writes access token to connector row via connectors.Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SPAMount added in v0.22.2

func SPAMount() (assetURL, base string)

SPAMount exposes the manager SPA's entry bundle URL and client-side route base so another host (e.g. the Agents shell) can render the same SPA inside its own chrome without duplicating the embed/asset wiring. Assets keep loading from the manager asset handler at spaAssetBase and the client router keeps its /manager base, so every in-SPA API call and internal navigation resolves against the live /manager/* routes. The host is just a different outer shell around the same #app div.

Types

type Handler

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

Handler wires the /manager/* routes. Manager owns job scheduling, runtime configs for jobs and tools, and the admin surface for connector rows.

func NewHandler

func NewHandler(svc *Service, configsSvc *configs.Service, connectorsSvc *connectors.Service, tagsSvc *tags.Service, usersSvc *login.Service, tools []tool.Tool) *Handler

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux, authMidd *login.Middleware)

Register wires /manager/* to mux. All pages require auth; admin-only actions (edits, regenerate, run) add RequireAdmin on top.

func (*Handler) RegisterConfigDecorator added in v0.9.0

func (h *Handler) RegisterConfigDecorator(toolKey string, fn func([]entity.Config) []entity.Config)

RegisterConfigDecorator registers a function that is called on the config rows for toolKey just before the manager detail page is rendered. Use it to inject dynamic Options (e.g. workspace names) into specific rows.

func (*Handler) SetCustomConnectors added in v0.17.0

func (h *Handler) SetCustomConnectors(svc *customconn.Service)

SetCustomConnectors late-binds the custom-connector service. The builder routes under /manager/connectors/custom/* render only when this is non-nil; the connectors index additionally shows the "+ New connector" dropdown and the "Custom" card badges.

type Service

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

Service manages job lifecycle: bootstrap from code-defined jobs, manual/scheduled execution, and result storage.

func NewService

func NewService(r *repo) *Service

func NewServiceFromDB

func NewServiceFromDB(db *gorm.DB) *Service

NewServiceFromDB is a convenience constructor for callers that only have a *gorm.DB (e.g. the worker process and the web server).

func (*Service) Bootstrap

func (s *Service) Bootstrap(ctx context.Context, mods []job.Module) error

Bootstrap syncs code-defined jobs with the jobs table. New jobs get a row with their default cron; existing rows keep admin-managed fields. One module registration = one row.

func (*Service) CancelJob added in v0.14.0

func (s *Service) CancelJob(ctx context.Context, key string) error

CancelJob cancels a running job by key. Returns error if job not running.

func (*Service) GetJob

func (s *Service) GetJob(ctx context.Context, key string) (*entity.Job, error)

func (*Service) GetRun

func (s *Service) GetRun(ctx context.Context, runID string) (*entity.JobRun, error)

func (*Service) ListEnabledJobs

func (s *Service) ListEnabledJobs(ctx context.Context) ([]entity.Job, error)

func (*Service) ListJobs

func (s *Service) ListJobs(ctx context.Context) ([]entity.Job, error)

func (*Service) ListRuns

func (s *Service) ListRuns(ctx context.Context, key string, limit int) ([]entity.JobRun, error)

func (*Service) ResetStuckForJob added in v0.14.6

func (s *Service) ResetStuckForJob(ctx context.Context, j *entity.Job) (bool, error)

ResetStuckForJob exposes the per-job stuck-run sweep so the worker tick can call it inline while iterating its enabled-jobs list. See repo.ResetStuckForJob for the conditions a run must meet to be classified as stuck.

func (*Service) RunCron

func (s *Service) RunCron(ctx context.Context, key string) (string, error)

RunCron triggers a job run initiated by the scheduler.

func (*Service) RunManual

func (s *Service) RunManual(ctx context.Context, key string, userID string) (string, error)

RunManual triggers a job run initiated by a user. Returns the run ID.

func (*Service) SetConfigReader

func (s *Service) SetConfigReader(c cfgReader)

SetConfigReader installs the configs-service view used to build a job.Ctx on every run. Called by wick at boot after both services have been constructed. Safe to skip in tests — Run() then sees a no-op Ctx where every Cfg(...) read returns "".

func (*Service) UpdateSchedule

func (s *Service) UpdateSchedule(ctx context.Context, key string, schedule string, enabled bool, maxRuns int, maxTimeoutMin int) error

Directories

Path Synopsis
templ: version: v0.3.1020
templ: version: v0.3.1020
type
templ: version: v0.3.1020
templ: version: v0.3.1020

Jump to

Keyboard shortcuts

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