service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 the installer saves new credentials, and it serves the health, installer, and application routes.

Index

Constants

View Source
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 Mode

type Mode int

Mode is how the service runs.

const (
	// ModeServer loads the configuration at startup and on reload.
	ModeServer Mode = iota
	// ModeLambda loads the configuration on first use, retrying in later
	// invocations until it succeeds.
	ModeLambda
)

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

func New(boot *config.Bootstrap, opts Options) (*Service, error)

New creates a Service. It does not load the application configuration; see Start and EnsureLoaded.

func (*Service) EnsureLoaded

func (s *Service) EnsureLoaded(ctx context.Context) (*app.App, error)

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

func (s *Service) Handler() http.Handler

Handler returns the service's HTTP handler.

func (*Service) Ready

func (s *Service) Ready() bool

Ready returns true when the configuration is loaded.

func (*Service) RunScheduled

func (s *Service) RunScheduled(ctx context.Context, action string) error

RunScheduled runs a scheduled action with a detached, bounded context.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

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.

func (*Service) Wait

func (s *Service) Wait(ctx context.Context) error

Wait waits until background jobs, such as webhook-triggered syncs, finish or ctx is done.

Jump to

Keyboard shortcuts

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