Documentation
¶
Index ¶
- Constants
- Variables
- func GetLocation(req *location.GetLocationRequest) (*location.Location, error)
- func ListLocations(req *location.ListLocationsRequest) ([]*location.Location, string, error)
- type ConfigProvider
- type Handler
- func (h *Handler) API() schedulerpb.CloudSchedulerServer
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) CreateJob(req *schedulerpb.CreateJobRequest) (*schedulerpb.Job, error)
- func (b *InMemoryBackend) DeleteJob(name string) error
- func (b *InMemoryBackend) DispatchDue()
- func (b *InMemoryBackend) Drain()
- func (b *InMemoryBackend) GetJob(name string) (*schedulerpb.Job, error)
- func (b *InMemoryBackend) ListJobs(req *schedulerpb.ListJobsRequest) ([]*schedulerpb.Job, string, error)
- func (b *InMemoryBackend) PauseJob(name string) (*schedulerpb.Job, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) ResumeJob(name string) (*schedulerpb.Job, error)
- func (b *InMemoryBackend) RunDispatcher(ctx context.Context, every time.Duration)
- func (b *InMemoryBackend) RunJob(name string) (*schedulerpb.Job, error)
- func (b *InMemoryBackend) SetAppEngineBaseURL(u string)
- func (b *InMemoryBackend) SetPublisher(p Publisher)
- func (b *InMemoryBackend) SetRunContext(ctx context.Context)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) UpdateJob(req *schedulerpb.UpdateJobRequest) (*schedulerpb.Job, error)
- type Provider
- type Publisher
- type Settings
Constants ¶
const ( // DefaultDispatchInterval is how often due jobs are picked up. DefaultDispatchInterval = 250 * time.Millisecond )
const DefaultPort = 8124
DefaultPort is the dedicated gRPC listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcpscheduler: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
func GetLocation ¶
func GetLocation(req *location.GetLocationRequest) (*location.Location, error)
GetLocation returns one supported location.
func ListLocations ¶
ListLocations lists the supported locations of a project.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPSchedulerSettings() Settings
}
ConfigProvider extracts Cloud Scheduler configuration from the AppContext Config.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// DispatchInterval is the dispatcher tick; zero disables the background dispatcher.
DispatchInterval time.Duration
Port int
// contains filtered or unexported fields
}
Handler serves the Cloud Scheduler gRPC API on a dedicated listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) API ¶
func (h *Handler) API() schedulerpb.CloudSchedulerServer
API exposes the CloudScheduler service for in-process callers (dashboard proxy).
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported gRPC methods.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler; the real API is gRPC on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Cloud Scheduler runs on its own gRPC listener.
func (*Handler) Shutdown ¶
Shutdown stops the gRPC server and dispatcher, aborting in-flight attempts.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all jobs under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) CreateJob ¶
func (b *InMemoryBackend) CreateJob(req *schedulerpb.CreateJobRequest) (*schedulerpb.Job, error)
CreateJob creates a job under a location.
func (*InMemoryBackend) DeleteJob ¶
func (b *InMemoryBackend) DeleteJob(name string) error
DeleteJob removes a job; in-flight attempts finish but their outcome is discarded.
func (*InMemoryBackend) DispatchDue ¶
func (b *InMemoryBackend) DispatchDue()
DispatchDue starts every attempt that is due: cron fires first, then pending retries.
func (*InMemoryBackend) Drain ¶
func (b *InMemoryBackend) Drain()
Drain blocks until every in-flight dispatch has finished.
func (*InMemoryBackend) GetJob ¶
func (b *InMemoryBackend) GetJob(name string) (*schedulerpb.Job, error)
GetJob returns a job.
func (*InMemoryBackend) ListJobs ¶
func (b *InMemoryBackend) ListJobs(req *schedulerpb.ListJobsRequest) ([]*schedulerpb.Job, string, error)
ListJobs lists the jobs of a location ordered by name.
func (*InMemoryBackend) PauseJob ¶
func (b *InMemoryBackend) PauseJob(name string) (*schedulerpb.Job, error)
PauseJob stops an ENABLED job from firing.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot; in-flight attempts at snapshot time are simply not resumed.
func (*InMemoryBackend) ResumeJob ¶
func (b *InMemoryBackend) ResumeJob(name string) (*schedulerpb.Job, error)
ResumeJob re-enables a PAUSED job, scheduling its next fire time from now.
func (*InMemoryBackend) RunDispatcher ¶
func (b *InMemoryBackend) RunDispatcher(ctx context.Context, every time.Duration)
RunDispatcher fires due jobs every interval until ctx ends.
func (*InMemoryBackend) RunJob ¶
func (b *InMemoryBackend) RunJob(name string) (*schedulerpb.Job, error)
RunJob forces an immediate attempt regardless of state or schedule; it returns before the attempt completes.
func (*InMemoryBackend) SetAppEngineBaseURL ¶
func (b *InMemoryBackend) SetAppEngineBaseURL(u string)
SetAppEngineBaseURL sets where AppEngineHttpTarget jobs are dispatched; empty disables them.
func (*InMemoryBackend) SetPublisher ¶
func (b *InMemoryBackend) SetPublisher(p Publisher)
SetPublisher wires the Pub/Sub emulator that PubsubTarget jobs publish into; nil disables them.
func (*InMemoryBackend) SetRunContext ¶
func (b *InMemoryBackend) SetRunContext(ctx context.Context)
SetRunContext sets the context in-flight dispatches run under; cancel it to abort them.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises jobs with their retry state.
func (*InMemoryBackend) UpdateJob ¶
func (b *InMemoryBackend) UpdateJob(req *schedulerpb.UpdateJobRequest) (*schedulerpb.Job, error)
UpdateJob updates the masked fields of a job (all mutable fields when the mask is empty).
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Cloud Scheduler. It serves gRPC on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Publisher ¶
type Publisher interface {
Publish(req *pubsubpb.PublishRequest) ([]string, error)
}
Publisher is the slice of the Pub/Sub emulator that PubsubTarget jobs publish into.
type Settings ¶
type Settings struct {
AppEngineBaseURL string `` //nolint:lll // config struct tags are intentionally verbose
/* 205-byte string literal not displayed */
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 207-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPScheduler.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.