Documentation
¶
Overview ¶
Package service runs the application for both entry points, the HTTP server and the Lambda function. It loads the configuration through a github-app-setup-go runtime, so the configuration can be loaded lazily, retried, and reloaded after an installer saves new credentials, and it serves the health, installer, Slack setup, and application routes.
Index ¶
- Constants
- type Mode
- type Options
- type Service
- func (s *Service) EnsureLoaded(ctx context.Context) (*app.App, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) Ready() bool
- func (s *Service) RunJob(ctx context.Context, job app.Job) error
- func (s *Service) RunScheduled(ctx context.Context, action string) error
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Wait(ctx context.Context) error
Constants ¶
const JobTimeout = app.JobTimeout
JobTimeout bounds a webhook, a scheduled action, or a background job. Requests run detached from the client, so a scheduled sync is not cut short when its caller disconnects.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Mode Mode
Logger *slog.Logger
// Env is where configuration is read from. Defaults to the process
// environment.
Env config.Env
// Store replaces the installer's credential store, for tests.
Store configstore.Store
// SlackStore and SlackAPI replace the Slack setup's credential store
// and Slack API, for tests.
SlackStore slackapp.Store
SlackAPI slackapp.API
// AppOptions are passed to app.New.
AppOptions []app.Option
// RetryInterval is the wait between load attempts in ModeLambda.
// Defaults to one second.
RetryInterval time.Duration
}
Options configures a Service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service serves the application and keeps its configuration loaded.
func New ¶
New creates a Service. It does not load the application configuration; see Start and EnsureLoaded.
func (*Service) EnsureLoaded ¶
EnsureLoaded loads the configuration if it is not loaded yet. It is for ModeLambda: a failed load is retried on the next call.
func (*Service) RunJob ¶ added in v1.1.0
RunJob runs a job started from Slack with a detached, bounded context.
func (*Service) RunScheduled ¶
RunScheduled runs a scheduled action with a detached, bounded context.
func (*Service) Start ¶
Start loads the configuration and then reloads it on SIGHUP or when the installer saves credentials, until ctx is done. It is for ModeServer. If the first load fails, Start returns the error, unless the installer is enabled: then the service keeps running so the app can be set up.