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 ¶
- Variables
- type Handler
- type Service
- func (s *Service) Bootstrap(ctx context.Context, mods []job.Module) error
- func (s *Service) GetJob(ctx context.Context, key string) (*entity.Job, error)
- func (s *Service) GetRun(ctx context.Context, runID string) (*entity.JobRun, error)
- func (s *Service) ListEnabledJobs(ctx context.Context) ([]entity.Job, error)
- func (s *Service) ListJobs(ctx context.Context) ([]entity.Job, error)
- func (s *Service) ListRuns(ctx context.Context, key string, limit int) ([]entity.JobRun, error)
- func (s *Service) RunCron(ctx context.Context, key string) (string, error)
- func (s *Service) RunManual(ctx context.Context, key string, userID string) (string, error)
- func (s *Service) SetConfigReader(c cfgReader)
- func (s *Service) UpdateSchedule(ctx context.Context, key string, schedule string, enabled bool, maxRuns int) error
Constants ¶
This section is empty.
Variables ¶
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 (*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
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 ¶
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 ¶
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) ListEnabledJobs ¶
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 "".