Documentation
¶
Overview ¶
Package destinations holds the Destinations (C-11.FR-18): Mattermost channels, Telegram channels, channels of a Bridge and Slack channels reached through a Connection, and outgoing webhooks. This package reads every type with its health and Routes and exports muster_destination_info, and deletes them (C-11.FR-14); the type capabilities add creating and editing them (C-13 to C-15, C-22, C-24). Secrets are read only as their status.
Index ¶
- Constants
- Variables
- type BridgeChannelCheck
- type BridgeChannelChecked
- type BridgeChecker
- type BridgeInput
- type ButtonSetInput
- type ChannelCheck
- type ChannelChecked
- type CheckFailedError
- type CheckItem
- type CheckResult
- type Destination
- type FieldError
- type Health
- type Healthy
- type Input
- type Limiter
- type ListFilter
- type MattermostChecker
- type MattermostInput
- type MentionValidator
- type MentionWarning
- type Page
- type Probe
- type Proxy
- type Ref
- type Renamed
- type Requester
- type Retire
- type RouteRef
- type Routes
- type Samples
- type Service
- func (s *Service) Check(ctx context.Context, publicID string) (CheckResult, error)
- func (s *Service) Create(ctx context.Context, r Requester, in Input) (Destination, error)
- func (s *Service) Delete(ctx context.Context, r Requester, publicID string, version *int64) error
- func (s *Service) Get(ctx context.Context, publicID string) (Destination, error)
- func (s *Service) InfoChanged()
- func (s *Service) List(ctx context.Context, f ListFilter) (Page, error)
- func (s *Service) Preview(ctx context.Context, publicID string, src Source) ([]delivery.PreviewItem, error)
- func (s *Service) RefreshInfo(ctx context.Context) error
- func (s *Service) RouteRefs(ctx context.Context, routeIDs []int64) (map[int64][]Ref, error)
- func (s *Service) RunInfo(ctx context.Context, ticks <-chan time.Time)
- func (s *Service) SetWriter(c WriterConfig)
- func (s *Service) Test(ctx context.Context, r Requester, publicID string, src Source) (TestResult, error)
- func (s *Service) Update(ctx context.Context, r Requester, publicID string, version *int64, in Input) (Destination, error)
- type SigningSecret
- type SlackChannelCheck
- type SlackChannelChecked
- type SlackChecker
- type SlackInput
- type Source
- type Store
- type TeamRef
- type TelegramChannelCheck
- type TelegramChannelChecked
- type TelegramChecker
- type TelegramInput
- type TemplateError
- type TestResult
- type Tester
- type TxQueries
- type UserRef
- type WebhookInput
- type Writer
- type WriterConfig
Constants ¶
const ( ActionDeleted = "destination.deleted" ResourceDestination = "destination" Hint = "destination" )
The Audit log action and resource type, and the live hint, of Destinations (C-03.FR-14).
const ( SourceAlertGroup = "alert_group" SourceExample = "example" )
The kinds of the source of a test or a preview (TestSource).
const ( TypeMattermost = "mattermost" TypeTelegram = "telegram" TypeWebhook = "webhook" TypeBridge = "bridge" TypeSlack = "slack" )
The Destination types.
const ( KindDestinationButtons = "destination_buttons" KindDestinationConnection = "destination_connection" OpenGroupUpdatesChannel = "muster_open_group_updates" )
KindDestinationButtons is the kind of the open_group_updates row that a changed button set of a Destination writes (C-28.FR-9), KindDestinationConnection that of a changed Connection (C-12.FR-12), and OpenGroupUpdatesChannel the LISTEN/NOTIFY channel that wakes the workers of internal/groups, which claim them.
const ( ActionCreated = "destination.created" ActionUpdated = "destination.updated" )
The Audit log actions of saved Destinations (C-03.FR-14).
const ( CodeRequired = "required" CodeInvalidFormat = "invalid_format" CodeTooLong = "too_long" CodeUnknownID = "unknown_id" CodeGatewayOnly = "gateway_only" CodeUnsupported = "unsupported" CodeCheckNotSupported = "check_not_supported" CodeCheckFailed = "destination_check_failed" )
The codes of FieldError; gateway_only refuses a Bridge Connection whose stored info declares only the role gateway (C-30.FR-1).
const ActionTested = "destination.tested"
The Audit log action of a Destination test (C-16.FR-5).
Variables ¶
var ( // ErrNameTaken is a name another Destination that is not deleted has. ErrNameTaken = errors.New("another destination has this name") // ErrUnknownConnection is a connection_id that names no Connection of the type: missing, deleted or of the other // messenger. ErrUnknownConnection = errors.New("no such connection of this type") )
var ErrNoTester = errors.New("this build has no test of destinations of this type")
ErrNoTester is a test or a preview of a Destination whose type has no Tester in this build: the API answers 501.
var ErrNotFound = errors.New("no such destination")
ErrNotFound is a Destination that does not exist in the Organization or is deleted.
var ErrVersionMismatch = errors.New("the destination changed since it was read")
ErrVersionMismatch is an If-Match that names another version of the Destination.
Functions ¶
This section is empty.
Types ¶
type BridgeChannelCheck ¶
BridgeChannelCheck is the Destination check of a Bridge channel through the Connection Connection (public_id), limited by that Connection alone, whether or not the Destination exists: its request posts nothing, and the Destination's limiter counts sends and edits (C-22.FR-3).
type BridgeChannelChecked ¶
type BridgeChannelChecked struct {
ConnectionID int64
Check bridge.ChannelCheck
}
BridgeChannelChecked is the result of a BridgeChannelCheck: the id of the Connection and the check.
type BridgeChecker ¶
type BridgeChecker interface {
CheckBridgeChannel(ctx context.Context, c BridgeChannelCheck) (BridgeChannelChecked, error)
// GatewayOnly reports whether the Connection connection (public_id) is a Bridge Connection whose stored info
// declares only the role gateway, a Notification gateway (C-30.FR-1); any other Connection, unknown ones included,
// is not.
GatewayOnly(ctx context.Context, connection string) (bool, error)
}
BridgeChecker runs the Destination check of a Bridge channel on the interactive path (C-22.FR-3), declared by its consumer next to TelegramChecker; *connections.Service implements it. A Connection that is not a Bridge Connection that is not deleted is ErrUnknownConnection; no limiter token within the budget is a *delivery.LimitedError.
type BridgeInput ¶
BridgeInput are the fields of a Bridge Destination (C-22.FR-3): its Connection by public_id and its channel id as its messenger names it.
type ButtonSetInput ¶
ButtonSetInput is the button set of a messenger Destination as a request writes it (DestinationButtonSet): its own, with the items, which Items nil leaves missing, or "As in the Organization".
type ChannelCheck ¶
ChannelCheck is the Destination check of a Mattermost channel through the Connection Connection (public_id), limited by that Connection alone, whether or not the Destination exists: its requests post nothing, and the Destination's limiter counts sends and edits (C-13.FR-2).
type ChannelChecked ¶
type ChannelChecked struct {
ConnectionID int64
Check mattermost.Check
}
ChannelChecked is the result of a ChannelCheck: the id of the Connection and the check.
type CheckFailedError ¶
type CheckFailedError struct {
Items []CheckItem
}
CheckFailedError is a save that its Destination check refused: nothing was saved. Items are the failing checks.
func (*CheckFailedError) Error ¶
func (e *CheckFailedError) Error() string
type CheckItem ¶
type CheckItem struct {
Name string
OK bool
Message string
Code string
MissingScopes []string
Pointer string
// AbsentUsers are, with the step discussion_group_members of a Telegram Destination, the people it saw outside the
// discussion group (C-27.FR-8).
AbsentUsers []UserRef
}
CheckItem is one step of a Destination check with its result: when it failed, its message, in English, its code, which clients translate (DestinationCheckItem.code), with missing_scope the scopes the bot token lacks, which clients name in their own words (D396), and, on a save, the field it concerns.
type CheckResult ¶
CheckResult is the result of checkDestination: whether every check passed, each check, the health after it, and the check run its requests share in the Request log (C-23.FR-5).
type Destination ¶
type Destination struct {
ID int64
PublicID string
Type string
Name string
Connection *string
MattermostTeamID *string
MattermostChannelID *string
MattermostTeamName *string
MattermostChannelName *string
TelegramChannelID *string
TelegramChannelChatID *string
TelegramDiscussionGroupID *string
TelegramChannelTitle *string
TelegramDiscussionGroupTitle *string
BridgeChannelID *string
BridgeChannelName *string
SlackChannelID *string
SlackChannelName *string
WebhookMode *string
EventsConfig json.RawMessage
TemplateConfig json.RawMessage
Proxy Proxy
SigningSecret SigningSecret
// SigningSecretOnce is the first Signing secret of an outgoing webhook, set only by Create, which returns it once.
SigningSecretOnce logging.Secret
MentionEntries []mentions.Entry
// MentionWarnings are the warnings about undelivered Mentions (C-28.FR-3), computed on every read.
MentionWarnings []MentionWarning
Buttons buttons.Own
OrganizationButtons buttons.Set
LimiterLimit int64
LimiterPerSeconds int64
Health Health
Routes []RouteRef
// Teams are the Teams that name the Destination as a Destination of the Team (C-26.FR-1), by name.
Teams []TeamRef
TemplateError *TemplateError
CreatedAt time.Time
Version int64
// OwningTeam is the Team that owns the Destination (C-25.FR-2), nil when none does.
OwningTeam *TeamRef
// ManagedBy is the tool that keeps the Destination as code, nil for none (C-33.FR-11).
ManagedBy *string
}
Destination is a Destination of any type as read. The fields of the other types are empty: Mattermost has its team and channel, Telegram its channel and the discussion group a Destination check found, a Bridge and Slack their channel id and the channel's name their Destination check read, an outgoing webhook its mode, request templates, proxy and Signing secret. EventsConfig and TemplateConfig are the stored JSON. MentionEntries are the Mention entries in order, with what each mentions now (C-28.FR-1); the L1 Mention settings are computed from them. Buttons is the button set of a messenger Destination, its own or "As in the Organization", and OrganizationButtons the Organization's set, which the latter follows (C-28.FR-8).
func (Destination) EffectiveButtons ¶
func (d Destination) EffectiveButtons() buttons.Set
EffectiveButtons is the button set the Root messages of d show: its own, else the Organization's (C-28.FR-8).
type FieldError ¶
FieldError is a field of a request that is not valid, at a JSON pointer of the request body, with a stable code of the validation-failed problem and, for a request template, the 1-based line and column of its error when known.
func (*FieldError) Error ¶
func (e *FieldError) Error() string
type Healthy ¶
Healthy ends the Broken state of the Destination destinationID after a successful Destination check started by a person (C-13.FR-10): delivery's MarkHealthy.
type Input ¶
type Input struct {
Type string
Name string
// MentionEntries are the Mention entries (C-28.FR-1), nil when the request omits them: none on a creation, the
// stored ones on an update. Mentions are the L1 Mention settings, nil when the request omits them, which a request
// without entries converts into entries until 0.3.0 (C-28.FR-5).
MentionEntries *[]mentions.EntryInput
Mentions mentions.Settings
Buttons *ButtonSetInput
Limiter Limiter
Mattermost *MattermostInput
Telegram *TelegramInput
Webhook *WebhookInput
Bridge *BridgeInput
Slack *SlackInput
// OwningTeamID is the public_id of the Team that owns the Destination (C-25.FR-2): nil keeps the stored one on an
// update and is none on a creation, and an empty string clears it.
OwningTeamID *string
// ManagedBy is the mark of the tool that keeps the Destination as code (C-33.FR-11).
ManagedBy managedby.Input
// contains filtered or unexported fields
}
Input is what createDestination and updateDestination write: the common fields and those of its type. Buttons is the button set of a messenger Destination, nil when the request omits it: "As in the Organization" on a creation, the stored set on an update; an outgoing webhook has none.
type ListFilter ¶
type ListFilter struct {
Type *string
Health *string
Route *string
Team *string
TeamUser *int64
After *int64
Limit int
}
ListFilter selects the Destinations of a page: of a type, a health, a Route (its public_id), owned by a Team (its public_id) and owned by a Team the User TeamUser is in, "My Teams", when set, after the id After, at most Limit.
type MattermostChecker ¶
type MattermostChecker interface {
CheckChannel(ctx context.Context, c ChannelCheck) (ChannelChecked, error)
}
MattermostChecker runs the Destination check of a Mattermost channel on the interactive path (C-13.FR-2, FR-10), declared by its consumer; *connections.Service implements it. A Connection that is not a Mattermost one that is not deleted is ErrUnknownConnection; no limiter token within the budget is a *delivery.LimitedError.
type MattermostInput ¶
MattermostInput are the fields of a Mattermost Destination: its Connection by public_id, its team and its channel.
type MentionValidator ¶
type MentionValidator interface {
Validate(ctx context.Context, destinationType string, set mentions.Settings, stored []mentions.EntryInput) error
ValidateEntries(ctx context.Context, c mentions.Check) ([]mentions.EntryInput, error)
Entries(ctx context.Context, db mentions.DBTX, ds []mentions.EntryDestination) (map[int64][]mentions.Entry, error)
WriteEntries(ctx context.Context, db mentions.DBTX, destinationID int64, entries []mentions.EntryInput,
now time.Time) error
}
MentionValidator validates the Mention settings of a Destination type (C-12.FR-8) and its Mention entries (C-28.FR-1, FR-2), reads the entries of Destinations with what they mention now and writes them, declared by its consumer; *mentions.Service implements it.
type MentionWarning ¶
type MentionWarning struct {
User mentions.UserRef
Mention mentions.Mention
Entry mentions.Entry
Messenger string
Reason string
Since time.Time
}
MentionWarning is a warning of a Destination about a person and a Mention entry whose latest "Mention not delivered" is not followed by a delivered Mention of that person through that entry (C-28.FR-3): the person, the entry as it is on the Destination now, the messenger — the Destination's type — the reason of the latest event and the time of the first one since the person's last delivered Mention through the entry. Through a bridge whose Mention line left out a group, a Team mention or everyone in the chat for length (C-12.FR-11), the warning is about that Mention and has no person.
type Page ¶
type Page struct {
Destinations []Destination
Next *int64
}
Page is a page of Destinations; Next is the cursor after its last one, nil on the last page.
type Probe ¶
Probe makes the probe of the Destination destinationID due at once when it is Broken, after a person saved it: delivery's ProbeNow.
type Proxy ¶
type Proxy struct {
Enabled bool `json:"enabled"`
Type *string `json:"type,omitempty"`
Address *string `json:"address,omitempty"`
Username *string `json:"username,omitempty"`
PasswordSet bool `json:"-"`
PasswordUpdatedAt *time.Time `json:"-"`
}
Proxy is the proxy of an outgoing webhook as stored, without its password; PasswordSet and PasswordUpdatedAt are the password's status.
type Renamed ¶
Renamed is the hook that delivery runs in the transaction tx that renamed the Destination publicID to name: every Internal alert about it takes the new name, as the same firing.
type Requester ¶
Requester is who asks for a change and how: the actor and the Transport of the Audit log entry, and the client address.
type Retire ¶
Retire is the hook that delivery runs in the transaction tx that deleted the Destination destinationID: the final edits of its open Root messages, and the wipe of its secrets once none is pending (C-11.FR-14).
type Routes ¶
Routes is the hook that routing runs in the transaction tx that deletes the Destination destinationID, before it leaves its Routes: each of them gets a new version and its hint, and its membership lock, so that no Alert Group of it is rendered for the Destination meanwhile.
type Samples ¶
type Samples interface {
TestSample(ctx context.Context, publicID string) (*messages.Source, error)
TestExample(ctx context.Context) (*messages.Source, error)
}
Samples read the Alert Group a test or a preview renders, declared by their consumer; *messages.Renderer implements them. An unknown Alert Group is messages.ErrNotFound.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service reads the Destinations of an Organization and deletes them.
func (*Service) Check ¶
Check runs the Destination check of the Destination publicID from checkDestination (C-13.FR-10, C-14.FR-14, C-22.FR-3, C-24.FR-3) on the interactive path, limited by its Connection alone, since a check posts nothing: each check with its result. A passing check of a Broken Destination ends its Broken state. A Bridge or Slack Destination's check keeps no channel name it reads: a save does. A Telegram Destination's check that passes keeps what its step discussion_group_members saw of the people of its Teams and of those its chains Page (C-27.FR-8), with them in the item's AbsentUsers. A type without a Destination check here is a *FieldError check_not_supported. Its requests are recorded as the kind destination_check with the Destination under one check run, which the result names (C-23.FR-2, FR-5).
func (*Service) Create ¶
Create creates a Mattermost Destination (C-13.FR-2, FR-3, C-11.FR-18) once its Destination check passed on the interactive path; the check reads the names of its team and channel, which the Destination keeps. A Telegram Destination is created the same way from its channel alone, keeping the discussion group its check found (C-14.FR-2), and a Bridge or Slack Destination from its channel id, keeping the channel's name its check read (C-22.FR-3, C-24.FR-3). An outgoing webhook in the events mode has no check: it is created with its first Signing secret (C-15.FR-1, FR-5). It is recorded as destination.created.
func (*Service) Delete ¶
Delete deletes the Destination publicID (C-11.FR-14); a non-nil version must be its current one. In one transaction it is marked deleted — it leaves every list and reads as missing, the row stays for history — it leaves every Route, each of which gets a new version and its hint through the Routes hook, delivery gives its open Root messages their final edit through the Retire hook, which also ends the waiting events of an outgoing webhook as Not delivered, and the Audit log entry destination.deleted is written. Its secrets are wiped once the final edits are done and no call of it is in flight. A deleted or unknown Destination is ErrNotFound. The deletion takes the membership locks of the Routes, then of the Teams, that name the Destination exclusively (routing's DestinationDeleted), while a transaction that changes several open Alert Groups at once, such as a Snapshot, may take Teams' locks shared out of id order: a deadlock PostgreSQL detects there rolls the deletion back, and it is run again, up to deletionAttempts times, rather than refused.
func (*Service) InfoChanged ¶
func (s *Service) InfoChanged()
InfoChanged asks RunInfo to refresh muster_destination_info: a hint said a Destination changed, maybe on another replica. It never blocks.
func (*Service) List ¶
List reads a page of the Destinations that are not deleted, in id order, with their Routes.
func (*Service) Preview ¶
func (s *Service) Preview(ctx context.Context, publicID string, src Source) ([]delivery.PreviewItem, error)
Preview renders, without sending anything, what the Destination publicID would receive for the source src (C-16.FR-4): the Root message of a Mattermost (Markdown, with the attachment as the request's body) or a Telegram (HTML) Destination, the envelope of a Bridge Destination or the body of chat.postMessage of a Slack Destination (as JSON), or the requests of an outgoing webhook — the event body in the events mode and "create", "update", "open thread" and "reply in thread" in the template mode — with every Secret masked. It takes no limiter token and records nothing.
func (*Service) RefreshInfo ¶
RefreshInfo sets muster_destination_info to the Destinations that are not deleted: a series per Destination with its current name; the series of a renamed or deleted one is removed. Each Destination also gets its counter series.
func (*Service) RouteRefs ¶
RouteRefs are the Destinations that are not deleted of each of the Routes routeIDs, by name, with their health (C-08.FR-1).
func (*Service) RunInfo ¶
RunInfo keeps muster_destination_info current until ctx ends: it refreshes it at once, after InfoChanged and at every tick, which also repairs a refresh that failed.
func (*Service) SetWriter ¶
func (s *Service) SetWriter(c WriterConfig)
SetWriter fills what the changes of Destinations need, before any change.
func (*Service) Test ¶
func (s *Service) Test(ctx context.Context, r Requester, publicID string, src Source) (TestResult, error)
Test runs the Destination test of the Destination publicID from s (C-16.FR-1 to FR-3, FR-5, FR-7): one test message to a messenger, or the test event and the "create" request of an outgoing webhook, through the interactive path. A step that found no limiter token in time is limited and sent nothing; the operation still succeeds. When every step succeeded on a Broken Destination its Broken state ends, as after a successful probe; a failed test changes nothing. Every test is recorded in the Audit log as destination.tested, with the source and each step's class, and logged as destination_tested; its requests are recorded as the kind test with the Destination under one check run, which the result names (C-23.FR-2, FR-5).
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, r Requester, publicID string, version *int64, in Input) (Destination, error)
Update replaces the configured fields of the Destination publicID (C-13.FR-2, FR-3, C-14.FR-2, C-22.FR-3, C-24.FR-3); a non-nil version must be its current one (If-Match). Saving runs the Destination check as Create does, limited by the Destination's Connection alone, since a check posts nothing; a passing check of a Broken Destination ends its Broken state (C-13.FR-10, C-14.FR-14). An update that changes nothing writes nothing, and one that changes only the mark managed_by of a Destination with a Destination check runs none (saveMark).
type SigningSecret ¶
SigningSecret is the status of the Signing secret of an outgoing webhook.
type SlackChannelCheck ¶
SlackChannelCheck is the Destination check of a Slack channel through the Connection Connection (public_id), limited by that Connection alone, whether or not the Destination exists: its request posts nothing, and the Destination's limiter counts sends and edits (C-24.FR-3).
type SlackChannelChecked ¶
type SlackChannelChecked struct {
ConnectionID int64
Check slack.ChannelCheck
}
SlackChannelChecked is the result of a SlackChannelCheck: the id of the Connection and the check.
type SlackChecker ¶
type SlackChecker interface {
CheckSlackChannel(ctx context.Context, c SlackChannelCheck) (SlackChannelChecked, error)
}
SlackChecker runs the Destination check of a Slack channel on the interactive path (C-24.FR-3), declared by its consumer next to BridgeChecker; *connections.Service implements it. A Connection that is not a Slack Connection that is not deleted is ErrUnknownConnection; no limiter token within the budget is a *delivery.LimitedError.
type SlackInput ¶
SlackInput are the fields of a Slack Destination (C-24.FR-3): its Connection by public_id and its channel id, C… or G…, as entered.
type Source ¶
Source is the source of a test or a preview (TestSource): a recent Alert Group of one of the Destination's Routes, by its public_id, or the built-in example.
type Store ¶
type Store interface {
ListDestinations(ctx context.Context, arg dbgen.ListDestinationsParams) ([]dbgen.ListDestinationsRow, error)
GetDestination(ctx context.Context, arg dbgen.GetDestinationParams) (dbgen.GetDestinationRow, error)
ListDestinationRoutes(ctx context.Context, arg dbgen.ListDestinationRoutesParams) (
[]dbgen.ListDestinationRoutesRow, error)
ListDestinationTeams(ctx context.Context, arg dbgen.ListDestinationTeamsParams) ([]dbgen.ListDestinationTeamsRow,
error)
ListRouteDestinationRefs(ctx context.Context, arg dbgen.ListRouteDestinationRefsParams) (
[]dbgen.ListRouteDestinationRefsRow, error)
ListDestinationInfo(ctx context.Context, orgID int64) ([]dbgen.ListDestinationInfoRow, error)
ListMentionWarnings(ctx context.Context, arg dbgen.ListMentionWarningsParams) ([]dbgen.ListMentionWarningsRow,
error)
}
Store are the queries of the package.
type TeamRef ¶
TeamRef names the Team that owns a Destination: its internal id, public_id, name and slug, and whether it was deleted.
type TelegramChannelCheck ¶
type TelegramChannelCheck struct {
Connection string
ChannelID string
People []telegram.GroupPerson
}
TelegramChannelCheck is the Destination check of a Telegram channel through the Connection Connection (public_id), limited by that Connection alone, whether or not the Destination exists: its requests post nothing, and the Destination's limiter counts sends and edits (C-14.FR-2). People are those whose membership of the discussion group its step discussion_group_members reads (C-27.FR-8), none before the Destination exists, since no Team or Route names it yet.
type TelegramChannelChecked ¶
type TelegramChannelChecked struct {
ConnectionID int64
Check telegram.DestinationCheck
}
TelegramChannelChecked is the result of a TelegramChannelCheck: the id of the Connection and the check.
type TelegramChecker ¶
type TelegramChecker interface {
CheckTelegramChannel(ctx context.Context, c TelegramChannelCheck) (TelegramChannelChecked, error)
}
TelegramChecker runs the Destination check of a Telegram channel on the interactive path (C-14.FR-2, FR-14), declared by its consumer next to MattermostChecker; *connections.Service implements it. A Connection that is not a Telegram one that is not deleted is ErrUnknownConnection; no limiter token within the budget is a *delivery.LimitedError.
type TelegramInput ¶
TelegramInput are the fields of a Telegram Destination (C-14.FR-2): its Connection by public_id and its channel, a chat id or an @username, as entered; its discussion group is found by its Destination check.
type TemplateError ¶
TemplateError is the template error state of an outgoing webhook request template.
type TestResult ¶
TestResult is the result of testDestination: each step, the health after the test, and the check run its requests share in the Request log (C-23.FR-5).
type Tester ¶
type Tester interface {
Test(ctx context.Context, in delivery.TestInput) ([]delivery.TestStep, error)
Preview(ctx context.Context, in delivery.TestInput) ([]delivery.PreviewItem, error)
}
Tester runs the test of one Destination type through the interactive path and renders its preview without sending anything (C-16), declared by its consumer; *mattermost.Tester, *telegram.Tester, *bridge.Tester, *slack.Tester and *webhooks.Tester implement it. An error is a failure of Muster itself, never of the Destination, whose failures are the steps' classes.
type TxQueries ¶
type TxQueries interface {
LockDestination(ctx context.Context, arg dbgen.LockDestinationParams) (dbgen.LockDestinationRow, error)
MarkDestinationDeleted(ctx context.Context, arg dbgen.MarkDestinationDeletedParams) error
DeleteDestinationRoutes(ctx context.Context, arg dbgen.DeleteDestinationRoutesParams) error
audit.Store
Notify(ctx context.Context, h db.Hint) error
// DB is the transaction the queries run in, which the Retire hook writes through.
DB() dbgen.DBTX
// contains filtered or unexported methods
}
TxQueries are the queries of a change of a Destination, with the insert of the Audit log and the live hint, in one transaction.
type WebhookInput ¶
type WebhookInput struct {
Mode string
Events *webhooks.EventsConfig
Template *webhooks.TemplateConfig
Proxy proxyconf.Input
}
WebhookInput are the fields of an outgoing webhook Destination (C-15.FR-1): its mode, the request of the events mode, the requests of the template mode and its proxy. Only the requests of the mode are stored: the events request in the modes events and both, the request templates in the modes template and both.
type WriterConfig ¶
type WriterConfig struct {
Writer Writer
Audit *audit.Writer
Business clock.Clock
Routes Routes
Retire Retire
Renamed Renamed
Mentions MentionValidator
Mattermost MattermostChecker
Telegram TelegramChecker
Bridge BridgeChecker
Slack SlackChecker
Healthy Healthy
Probe Probe
Keyring *keyring.Keyring
Templates *templates.Sandbox
Samples Samples
Testers map[string]Tester
Log *logging.Logger
}
WriterConfig is what the changes of Destinations need: the Writer, the Audit log, the business clock that dates the changes, routing's Routes hook and delivery's Retire and Renamed hooks; and for the saves, the validation of Mention settings, the Destination checks of the Mattermost, Telegram, Bridge and Slack types, delivery's end of a Broken state and its probe at once, and for outgoing webhooks the Keyring that encrypts their secrets and the template sandbox that checks their request. Destination tests and previews (C-16) read their sources through Samples, run through the Tester of each type and log through Log.