dispatcher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BackoffInitialDelay             time.Duration `env:"BACKOFF_INITIAL_DELAY,default=500ms"`
	Environment                     string        `env:"ENVIRONMENT,default=production"`
	GitHubAPIBaseURL                string        `env:"GITHUB_API_BASE_URL,default=https://api.github.com"`
	GitHubAppID                     string        `env:"GITHUB_APP_ID,required"`
	KMSAppPrivateKeyID              string        `env:"KMS_APP_PRIVATE_KEY_ID,required"`
	MaxRetryAttempts                int           `env:"MAX_RETRY_ATTEMPTS,default=3"`
	RunnerExecutionTimeoutSeconds   int           `env:"RUNNER_EXECUTION_TIMEOUT_SECONDS,default=3600"`
	RunnerIdleTimeoutSeconds        int           `env:"RUNNER_IDLE_TIMEOUT_SECONDS,default=300"`
	RunnerImageName                 string        `env:"RUNNER_IMAGE_NAME,default=default-runner"`
	RunnerImageTag                  string        `env:"RUNNER_IMAGE_TAG,default=latest"`
	RunnerLocation                  string        `env:"RUNNER_LOCATION,required"`
	RunnerProjectID                 string        `env:"RUNNER_PROJECT_ID,required"`
	RunnerRepositoryID              string        `env:"RUNNER_REPOSITORY_ID,required"`
	RunnerServiceAccount            string        `env:"RUNNER_SERVICE_ACCOUNT,required"`
	RunnerDefaultLabel              string        `env:"RUNNER_DEFAULT_LABEL,required"`
	RunnerWorkerPoolID              string        `env:"RUNNER_WORKER_POOL_ID"`
	Runner404Enabled                bool          `env:"RUNNER_404_ENABLED,default=false"`
	Runner404DefaultFromEnvDisabled bool          `env:"RUNNER_404_DEFAULT_FROM_ENV_DISABLED,default=false"`
	Runner404ImageName              string        `env:"RUNNER_404_IMAGE_NAME,default=runner-404"`
	Runner404ImageTag               string        `env:"RUNNER_404_IMAGE_TAG,default=latest"`
	Runner404Location               string        `env:"RUNNER_404_LOCATION,required"`
	Runner404ProjectID              string        `env:"RUNNER_404_PROJECT_ID,required"`
	Runner404ServiceAccount         string        `env:"RUNNER_404_SERVICE_ACCOUNT,required"`
	Runner404WorkerPoolID           string        `env:"RUNNER_404_WORKER_POOL_ID"`
	Runner404ExtraRunnerCount       int           `env:"RUNNER_404_EXTRA_RUNNER_COUNT,default=0"`
	RunnerRegistryDefaultKeyPrefix  string        `env:"RUNNER_REGISTRY_DEFAULT_KEY_PREFIX,default=default"`
	RunnerLabelAliasesRaw           []string      `env:"RUNNER_LABEL_ALIASES"`
	RunnerLabelAliases              map[string]string
	SupportedRunnerLabels           []string `env:"SUPPORTED_RUNNER_LABELS,required,delimiter=,"`
	IgnoredRunnerLabels             []string `env:"IGNORED_RUNNER_LABELS,required,delimiter=,"`
	PubSubSubscription              string   `env:"PUBSUB_SUBSCRIPTION,required"`
	PubSubProjectID                 string   `env:"PUBSUB_PROJECT_ID,required"`
	Port                            string   `env:"PORT,default=8080"`
	PubSubMaxDeliveryAttempts       int      `env:"PUBSUB_MAX_DELIVERY_ATTEMPTS,default=5"`
	RunsOnURIParsingEnabled         bool     `env:"RUNS_ON_URI_PARSING_ENABLED,default=false"`
}

Config defines the set of environment variables required for running the pubsub service.

func NewConfig

func NewConfig(ctx context.Context) (*Config, error)

NewConfig creates a new Config from environment variables.

func (*Config) ToFlags

func (cfg *Config) ToFlags(set *cli.FlagSet) *cli.FlagSet

ToFlags binds the config to the cli.FlagSet and returns it.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate validates the pubsub config after load.

type KeyManagement

type KeyManagement struct {
	// contains filtered or unexported fields
}

KeyManagement provides a client and dataset identifiers.

func NewKeyManagement

func NewKeyManagement(ctx context.Context, opts ...option.ClientOption) (*KeyManagement, error)

NewKeyManagementClient creates a new instance of a KMS client.

func (*KeyManagement) Close

func (km *KeyManagement) Close() error

Close releases any resources held by the KeyManagement client.

func (*KeyManagement) CreateSigner

func (km *KeyManagement) CreateSigner(ctx context.Context, kmsAppPrivateKeyID string) (*gcpkms.Signer, error)

CreateSigner leverages the gcpkms package to create a signer.

type KeyManagementClient

type KeyManagementClient interface {
	Close() error
	CreateSigner(ctx context.Context, kmsAppPrivateKeyID string) (*gcpkms.Signer, error)
}

KeyManagementClient adheres to the interaction the pubsub service has with a subset of Key Management APIs.

type MockKMSClient

type MockKMSClient struct{}

MockKMSClient is a mock for the KeyManagementClient interface.

func (*MockKMSClient) Close

func (m *MockKMSClient) Close() error

Close implements the KeyManagementClient interface.

func (*MockKMSClient) CreateSigner

func (m *MockKMSClient) CreateSigner(ctx context.Context, kmsAppPrivateKeyID string) (*gcpkms.Signer, error)

CreateSigner implements the KeyManagementClient interface.

type PrivateURI

type PrivateURI struct {
	Label    string
	ImageTag string // Will be an empty string if the query parameter is not present.
}

PrivateURI holds the parsed and validated components of our custom URI.

func ParsePrivateURI

func ParsePrivateURI(uriStr string) (*PrivateURI, error)

ParsePrivateURI validates and parses a string into a PrivateURI struct. It returns a pointer to the struct on success, or an error if validation fails.

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber handles receiving and processing events from Pub/Sub.

func NewSubscriber

func NewSubscriber(ctx context.Context, cfg *Config, rc *redis.Client, opts *SubscriberOptions) (*Subscriber, error)

NewSubscriber creates a new Subscriber instance.

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close handles the graceful shutdown of clients.

func (*Subscriber) Routes

func (s *Subscriber) Routes(ctx context.Context) http.Handler

Routes creates a ServeMux for all the routes that this Router supports.

func (*Subscriber) RunPubSubSubscriber

func (s *Subscriber) RunPubSubSubscriber(ctx context.Context) error

RunPubSubSubscriber starts a blocking loop to receive messages from Pub/Sub.

type SubscriberOptions

type SubscriberOptions struct {
	CloudBuildClientOpts    []option.ClientOption
	KeyManagementClientOpts []option.ClientOption
	PubSubClientOpts        []option.ClientOption

	CloudBuildClientOverride    cloudbuild.Client
	GitHubClientOverride        gh.Client
	KeyManagementClientOverride KeyManagementClient
}

SubscriberOptions encapsulate client config options as well as dependency implementation overrides.

Jump to

Keyboard shortcuts

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