factory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package factory wires concrete dependencies for the maintainer-watcher-github-pr binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommandConsumer

func CreateCommandConsumer(
	saramaClientProvider libkafka.SaramaClientProvider,
	syncProducer libkafka.SyncProducer,
	db libkv.DB,
	ghClient pkg.GitHubClient,
	createSender task.CreateCommandSender,
	taskCreationFilter filter.TaskCreationFilter,
	trustDecision trust.Trust,
	stage string,
	maxSlugLen int,
	maxTitleLen int,
	taskSuffix string,
	targetVault string,
	metrics pkg.Metrics,
	topicPrefix base.TopicPrefix,
	currentDateTime libtime.CurrentDateTimeGetter,
) run.Func

CreateCommandConsumer wires a run.Func that consumes TriggerPRReviewCommand messages from the github-pr watcher's request topic and runs them through the single-PR review pipeline (GitHub fetch → filter → trust → publish).

currentDateTime is the injected libtime.CurrentDateTimeGetter passed through to the trigger executor so it can derive a time-salted task identifier when the TriggerPRReviewCommand has Force=true (spec 067). The non-force path does not consult the clock.

The function is pure composition: no business logic, no conditionals. It uses cdb.RunCommandConsumerTxDefault (auto-wraps the transaction) per the go-cqrs/auto-tx-wrapper-no-manual-wrap rule — do NOT manually wrap the executor with kv.NewTransactionMiddleware.

func CreateGitHubAppClient

func CreateGitHubAppClient(
	ctx context.Context,
	appID int64,
	installationID int64,
	pemKey []byte,
) (*http.Client, error)

CreateGitHubAppClient creates an HTTP client authenticated as a GitHub App installation.

func CreateKafkaSender

func CreateKafkaSender(
	syncProducer libkafka.SyncProducer,
	topicPrefix base.TopicPrefix,
) task.CreateCommandSender

CreateKafkaSender constructs a typed create-task command sender backed by a Kafka sync producer.

func CreateSinglePRTriggerHandler

func CreateSinglePRTriggerHandler(
	sender command.TriggerPRReviewCommandSender,
) handler.SinglePRTriggerHandler

CreateSinglePRTriggerHandler wires the thin CQRS handler that publishes a TriggerPRReviewCommand to Kafka for each valid /trigger request. All GitHub/filter/trust work lives in the in-pod command consumer (see pkg/command.NewTriggerPRReviewCommandExecutor).

func CreateTriggerPRReviewCommandSender

func CreateTriggerPRReviewCommandSender(
	ctx context.Context,
	syncProducer libkafka.SyncProducer,
	topicPrefix base.TopicPrefix,
) command.TriggerPRReviewCommandSender

CreateTriggerPRReviewCommandSender constructs a typed trigger-PR-review command sender backed by a Kafka sync producer. This is the HTTP-side sender: the /trigger handler publishes TriggerPRReviewCommand messages through it.

CommandCreator and Initiator are built once here and reused across every SendCommand call (per cqrs/docs/producing-commands.md "Factory Wiring"; matches trading/frontend/command's reference impl).

func CreateWatcher

func CreateWatcher(
	ghClient pkg.GitHubClient,
	createSender task.CreateCommandSender,
	cursorPath string,
	startTime libtime.DateTime,
	scope string,
	taskCreationFilter filter.TaskCreationFilter,
	stage string,
	metrics pkg.Metrics,
	trustDecision trust.Trust,
	maxSlugLen int,
	maxTitleLen int,
	taskSuffix string,
	targetVault string,
) pkg.Watcher

CreateWatcher wires all dependencies and returns a ready-to-use Watcher.

Types

This section is empty.

Jump to

Keyboard shortcuts

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