Documentation
¶
Overview ¶
Package async provides interfaces for async infrastructure provisioning.
Index ¶
- Variables
- type KafkaAdmin
- type KafkaAdminFactory
- type KafkaProvisioner
- func (k *KafkaProvisioner) Name() string
- func (k *KafkaProvisioner) Provision(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
- func (k *KafkaProvisioner) Teardown(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) error
- type NoopProvisioner
- type ProvisionResult
- type Provisioner
- type TemporalProvisioner
- func (t *TemporalProvisioner) Name() string
- func (t *TemporalProvisioner) Provision(_ context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
- func (t *TemporalProvisioner) Teardown(_ context.Context, _ *v1alpha1.Environment, _ v1alpha1.AsyncRouteSpec) error
- type WebhookProvisioner
- func (w *WebhookProvisioner) Name() string
- func (w *WebhookProvisioner) Provision(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
- func (w *WebhookProvisioner) Teardown(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) error
- type WebhookRequest
- type WebhookResponse
Constants ¶
This section is empty.
Variables ¶
var ErrNilProvisionResult = errors.New("provisioner returned nil result")
ErrNilProvisionResult is returned when a provisioner returns nil result without an error.
var Providers = registry.New[Provisioner]("async-provisioner")
Providers is the registry for async provisioners.
Functions ¶
This section is empty.
Types ¶
type KafkaAdmin ¶
type KafkaAdmin interface {
CreateTopics(ctx context.Context, partitions int32, replication int16, configs map[string]*string, topics ...string) (kadm.CreateTopicResponses, error)
DeleteTopics(ctx context.Context, topics ...string) (kadm.DeleteTopicResponses, error)
Close()
}
KafkaAdmin abstracts the Kafka admin operations for testability.
type KafkaAdminFactory ¶
type KafkaAdminFactory func(brokers []string) (KafkaAdmin, error)
KafkaAdminFactory creates KafkaAdmin instances. Defaults to real kadm.Client.
type KafkaProvisioner ¶
type KafkaProvisioner struct {
Brokers []string
NumPartitions int32
ReplicationFactor int16
AdminFactory KafkaAdminFactory // nil = use real kadm
}
KafkaProvisioner provisions Kafka topics and consumer groups for preview environments using the Kafka AdminClient API. Compatible with Apache Kafka, AutoMQ, Redpanda, MSK, and any Kafka-protocol broker.
func (*KafkaProvisioner) Name ¶
func (k *KafkaProvisioner) Name() string
Name returns the provisioner name.
func (*KafkaProvisioner) Provision ¶
func (k *KafkaProvisioner) Provision(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
func (*KafkaProvisioner) Teardown ¶
func (k *KafkaProvisioner) Teardown(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) error
Teardown deletes the preview-scoped Kafka topic.
type NoopProvisioner ¶
type NoopProvisioner struct{}
NoopProvisioner is a no-op provisioner that returns the target unchanged.
func (*NoopProvisioner) Name ¶
func (n *NoopProvisioner) Name() string
Name returns the provisioner name.
func (*NoopProvisioner) Provision ¶
func (n *NoopProvisioner) Provision(_ context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
Provision returns a resolved target of "<target>-<envName>" and populates default or custom environment variables without creating real infrastructure.
func (*NoopProvisioner) Teardown ¶
func (n *NoopProvisioner) Teardown(_ context.Context, _ *v1alpha1.Environment, _ v1alpha1.AsyncRouteSpec) error
Teardown is a no-op since no real infrastructure was created.
type ProvisionResult ¶
type ProvisionResult struct {
// ResolvedTarget is the provisioned resource name (e.g., "preview-123-payments" task queue).
ResolvedTarget string
// EnvVars are environment variables to inject into preview pods.
EnvVars map[string]string
}
ProvisionResult contains the result of provisioning an async route.
type Provisioner ¶
type Provisioner interface {
// Provision creates async infrastructure for the given route spec.
Provision(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
// Teardown removes async infrastructure for the given route spec.
Teardown(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) error
// Name returns the provisioner name.
Name() string
}
Provisioner provisions and tears down async infrastructure for preview environments.
type TemporalProvisioner ¶
type TemporalProvisioner struct {
// Namespace is the Temporal namespace to use.
Namespace string
}
TemporalProvisioner provisions Temporal task queues for preview environments. Task queues in Temporal are lazy — they auto-create when a worker polls. This provisioner generates deterministic queue names and injects them as env vars.
func (*TemporalProvisioner) Name ¶
func (t *TemporalProvisioner) Name() string
Name returns the provisioner name.
func (*TemporalProvisioner) Provision ¶
func (t *TemporalProvisioner) Provision(_ context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
Provision generates a preview-scoped task queue name. Temporal task queues auto-create on first worker poll, so no actual provisioning is needed.
func (*TemporalProvisioner) Teardown ¶
func (t *TemporalProvisioner) Teardown(_ context.Context, _ *v1alpha1.Environment, _ v1alpha1.AsyncRouteSpec) error
Teardown is a no-op for Temporal — stale task queues are harmless and are garbage-collected by Temporal when no workers are polling.
type WebhookProvisioner ¶
WebhookProvisioner calls an external webhook to provision async infrastructure.
func NewWebhookProvisioner ¶
func NewWebhookProvisioner(endpoint string) *WebhookProvisioner
NewWebhookProvisioner creates a WebhookProvisioner targeting the given endpoint URL.
func (*WebhookProvisioner) Name ¶
func (w *WebhookProvisioner) Name() string
Name returns the provisioner name.
func (*WebhookProvisioner) Provision ¶
func (w *WebhookProvisioner) Provision(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) (*ProvisionResult, error)
Provision calls the webhook endpoint to create async infrastructure and returns the resolved target and environment variables to inject into preview pods.
func (*WebhookProvisioner) Teardown ¶
func (w *WebhookProvisioner) Teardown(ctx context.Context, env *v1alpha1.Environment, route v1alpha1.AsyncRouteSpec) error
Teardown calls the webhook endpoint to remove async infrastructure for the given route.
type WebhookRequest ¶
type WebhookRequest struct {
Action string `json:"action"` // "provision" or "teardown"
Environment string `json:"environment"`
Namespace string `json:"namespace"`
Route v1alpha1.AsyncRouteSpec `json:"route"`
}
WebhookRequest is sent to the provisioning webhook.
type WebhookResponse ¶
type WebhookResponse struct {
ResolvedTarget string `json:"resolvedTarget"`
EnvVars map[string]string `json:"envVars"`
}
WebhookResponse is returned by the provisioning webhook.