workflows

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommentPollingWindow   = 10 * time.Minute
	CommentPollingInterval = 19 * time.Second
	CommentPollingJitter   = 4 * time.Second

	PollingCleanupTimeout = 5 * time.Minute
)

Variables

View Source
var PullRequestSignals = []string{
	"bitbucket.events.pullrequest.created",
	"bitbucket.events.pullrequest.updated",
	"bitbucket.events.pullrequest.approved",
	"bitbucket.events.pullrequest.unapproved",
	"bitbucket.events.pullrequest.changes_request_created",
	"bitbucket.events.pullrequest.changes_request_removed",
	"bitbucket.events.pullrequest.fulfilled",
	"bitbucket.events.pullrequest.rejected",

	"bitbucket.events.pullrequest.comment_created",
	"bitbucket.events.pullrequest.comment_updated",
	"bitbucket.events.pullrequest.comment_deleted",
	"bitbucket.events.pullrequest.comment_resolved",
	"bitbucket.events.pullrequest.comment_reopened",
}

PullRequestSignals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.

This is based on:

View Source
var RepositorySignals = []string{
	"bitbucket.events.repo.commit_comment_created",

	"bitbucket.events.repo.commit_status_created",
	"bitbucket.events.repo.commit_status_updated",
}

RepositorySignals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.

This is based on:

View Source
var Schedules = []string{
	"bitbucket.schedules.poll_comment",
	"bitbucket.schedules.polling_cleanup",
}

Schedules is a list of workflow names that RevChat runs periodically via Temporal schedules (https://docs.temporal.io/develop/go/schedules).

Functions

func CommentReopenedWorkflow

func CommentReopenedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

CommentReopenedWorkflow mirrors the reopening of a resolved PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-reopened

func CommentResolvedWorkflow

func CommentResolvedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

CommentResolvedWorkflow mirrors the resolution of a PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-resolved

func CommitCommentCreatedWorkflow

func CommitCommentCreatedWorkflow(ctx workflow.Context, _ bitbucket.RepositoryEvent) error

CommitCommentCreatedWorkflow (will) handle (in the future) this event: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Commit-comment-created

func CreateSchedule added in v1.2.0

func CreateSchedule(ctx context.Context, c client.Client, taskQueue string)

CreateSchedule starts a scheduled workflow that runs once an hour, to delete obsolete (i.e. completed) PR comment polling schedules (which were started by [Config.pollCommentForUpdates]) instead of waiting a week for the Temporal server to do it.

func DrainPullRequestSignals

func DrainPullRequestSignals(ctx workflow.Context) bool

DrainPullRequestSignals drains all pending PullRequestSignals channels, and waits for their corresponding workflow executions to complete in order. This is called in preparation for resetting the dispatcher workflow's history.

func DrainRepositorySignals

func DrainRepositorySignals(ctx workflow.Context) bool

DrainRepositorySignals drains all pending RepositorySignals channels, and waits for their corresponding workflow executions to complete in order. This is called in preparation for resetting the dispatcher workflow's history.

func RegisterPullRequestSignals

func RegisterPullRequestSignals(ctx workflow.Context, sel workflow.Selector)

RegisterPullRequestSignals routes PullRequestSignals to their registered workflows.

func RegisterPullRequestWorkflows

func RegisterPullRequestWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)

RegisterPullRequestWorkflows maps event-handling workflow functions to PullRequestSignals.

func RegisterRepositorySignals

func RegisterRepositorySignals(ctx workflow.Context, sel workflow.Selector)

RegisterRepositorySignals routes RepositorySignals to their registered workflows.

func RegisterRepositoryWorkflows

func RegisterRepositoryWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)

RegisterRepositoryWorkflows maps event-handling workflow functions to RepositorySignals.

Types

type Config

type Config struct {
	SlackAlertsChannel        string
	SlackChannelNamePrefix    string
	SlackChannelNameMaxLength int
	SlackChannelsArePrivate   bool

	LinkifyMap map[string]string

	Opts      client.Options
	TaskQueue string
}

func (Config) CommentCreatedWorkflow

func (c Config) CommentCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

CommentCreatedWorkflow mirrors the creation of a new PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-created.1

func (Config) CommentDeletedWorkflow

func (c Config) CommentDeletedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

CommentDeletedWorkflow mirrors the deletion of a PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-deleted

func (Config) CommentUpdatedWorkflow

func (c Config) CommentUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

CommentUpdatedWorkflow mirrors an edit of an existing PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-updated

Note: these events are not reported by Bitbucket if they occur within a 10-minute window after the creation or last update of the same PR comment. As a workaround, we actively poll Bitbucket to detect text changes within these windows: see Config.PollCommentWorkflow.

func (Config) CommitStatusWorkflow added in v1.3.2

func (c Config) CommitStatusWorkflow(ctx workflow.Context, event bitbucket.RepositoryEvent) error

CommitStatusWorkflow mirrors build/commit status updates in the corresponding PR's Slack channel:

func (Config) PollCommentWorkflow

func (c Config) PollCommentWorkflow(ctx workflow.Context, req PollCommentRequest) error

PollCommentWorkflow checks a specific PR comment to detect and mirror edits made within Bitbucket's [10-minute silent window] after its creation or last update, instead of [CommentUpdatedWorkflow]. This workflow runs in a Temporal schedule, roughly every CommentPollingInterval during CommentPollingWindow, or until the comment is deleted.

This workflow uses a checksum of the comment's text for privacy and efficiency reasons.

func (Config) PollingCleanupWorkflow added in v1.2.0

func (c Config) PollingCleanupWorkflow(ctx workflow.Context) error

PollingCleanupWorkflow deletes obsolete (i.e. completed) PR comment polling schedules. This workflow runs once an hour in a Temporal schedule, and is a trivial wrapper for [deleteSchedulesActivity].

func (Config) PullRequestClosedWorkflow added in v1.3.2

func (c Config) PullRequestClosedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

PullRequestClosedWorkflow archives a PR's Slack channel when the PR is merged or declined/rejected:

func (Config) PullRequestCreatedWorkflow

func (c Config) PullRequestCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

PullRequestCreatedWorkflow initializes a new Slack channel for a newly-created PR: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Created.1

func (Config) PullRequestUpdatedWorkflow

func (c Config) PullRequestUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error

PullRequestUpdatedWorkflow mirrors various PR updates in the PR's Slack channel (such as title/description edits, reviewer changes, commit pushes, and branch retargeting): https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Updated.2

type PollCommentRequest added in v1.2.0

type PollCommentRequest struct {
	ThrippyID  string `json:"thrippy_id"`
	CommentURL string `json:"comment_url"`
	Checksum   string `json:"checksum"`
}

PollCommentRequest is the input to Config.PollCommentWorkflow.

Jump to

Keyboard shortcuts

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