manager

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

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

Storage:

  • OAuth App credentials: configs owner "connector_oauth:{key}" keys: "client_id", "client_secret"
  • 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

View Source
var StaticFS embed.FS

Functions

This section is empty.

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.

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) 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) 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) 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