config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config is the configuration the Slack plugin reads: its [plugins.slack] table and the host keys its manifest's config_reads names, as the host passes them.

Index

Constants

View Source
const Day = 24 * time.Hour

Day is what d means: 24 hours.

View Source
const DefaultSlackEndedAfter = 7 * 24 * time.Hour

DefaultSlackEndedAfter is plugins.slack.ended_after's default.

View Source
const DefaultSlackRedirectPort = 53682

DefaultSlackRedirectPort is the login callback port registered in the Slack app.

View Source
const DefaultWarmFor = 72 * time.Hour

DefaultWarmFor is items.heat.warm_for when unset.

View Source
const MinSlackTurnChars = 2000

MinSlackTurnChars is the smallest cap Chars returns, which holds a parent and a reply.

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration reads s, a Go duration such as 10m or 1h30m, or a whole number of days such as 7d; zero and negative durations are refused.

Types

type Config

type Config struct {
	Slack Slack
	// Placement are the host's placement rules.
	Placement []PlacementRule
	Items     Items
	// Brand is the host's name, which names the default Keychain service.
	Brand string
}

Config is what the plugin reads of the host's configuration.

func Parse

func Parse(c source.Config, brand string) (Config, error)

Parse reads c, the configuration the host passes; brand is the host's name.

func (Config) Service

func (c Config) Service() string

Service is the Keychain service of the tokens.

type Days

type Days time.Duration

Days is a duration written as a Go duration or a whole number of days: "2d", "36h", "90m".

func (*Days) UnmarshalJSON

func (d *Days) UnmarshalJSON(b []byte) error

type Items

type Items struct {
	Heat ItemsHeat `json:"heat"`
}

Items holds the host's items ledger settings the plugin reads.

type ItemsHeat

type ItemsHeat struct {
	// WarmFor is how long a unit stays warm after its last item resolved; zero is DefaultWarmFor.
	WarmFor Days `json:"warm_for,omitempty"`
}

func (ItemsHeat) WarmForOr

func (h ItemsHeat) WarmForOr() time.Duration

WarmForOr is how long a unit stays warm after its last item resolved.

type PlacementRule

type PlacementRule struct {
	Match    string `json:"match"`
	Repo     string `json:"repo,omitempty"`
	Checkout string `json:"checkout,omitempty"`
	Role     string `json:"role,omitempty"`
	Shared   bool   `json:"shared,omitempty"`
}

PlacementRule places the work of what matches Match.

type Slack

type Slack struct {
	// ClientID is the Slack app's client id; empty leaves Slack unconfigured.
	ClientID     string `json:"client_id"`
	RedirectPort int    `json:"redirect_port"`
	// KeychainService names the Keychain items; empty is the brand's name plus "-slack".
	KeychainService string `json:"keychain_service"`
	// PostAllowlist, when not empty, holds the only channel ids, or user ids naming
	// the DM with that user, a post may go to.
	PostAllowlist []string `json:"post_allowlist"`
	// RequestLog logs one line per Slack call: method and HTTP status.
	RequestLog bool            `json:"request_log"`
	Ingest     SlackIngest     `json:"ingest"`
	Extraction SlackExtraction `json:"extraction"`
	Turns      SlackTurns      `json:"turns"`
	// EndedAfter is how long a unit stays quiet before it has ended; zero is DefaultSlackEndedAfter.
	EndedAfter Days `json:"ended_after,omitempty"`
}

Slack holds the Slack source's settings; no secret lives here.

func (Slack) Configured

func (s Slack) Configured() bool

func (Slack) EndedAfterFor

func (s Slack) EndedAfterFor() time.Duration

EndedAfterFor is how long a Slack unit stays quiet before it has ended.

func (Slack) Port

func (s Slack) Port() int

type SlackExtraction

type SlackExtraction struct {
	// Enabled nil is on.
	Enabled *bool `json:"enabled,omitempty"`
	// Tier is fast, balanced or frontier; empty is fast.
	Tier       string  `json:"tier,omitempty"`
	Language   string  `json:"language,omitempty"`
	PerCallUSD float64 `json:"per_call_usd,omitempty"`
	PerDayUSD  float64 `json:"per_day_usd,omitempty"`
	PerDay     int     `json:"per_day,omitempty"`
	// Quiet is how long a unit stays unchanged before it runs; MaxWait bounds the delay of its oldest change.
	Quiet       Days `json:"quiet,omitempty"`
	MaxWait     Days `json:"max_wait,omitempty"`
	WindowChars int  `json:"window_chars,omitempty"`
	// MaxFailures failed calls in a row make the job give up on a unit until its next change.
	MaxFailures int `json:"max_failures,omitempty"`
	// ContextMessages and ContextChars bound the read-only messages shown before a DM's window; -1 turns either off.
	ContextMessages int `json:"context_messages,omitempty"`
	ContextChars    int `json:"context_chars,omitempty"`
	// EscalateOverChars sends a unit whose rendered conversation is longer to the frontier tier; 0 or -1 is off.
	EscalateOverChars int `json:"escalate_over_chars,omitempty"`
}

SlackExtraction sets the extraction job; a zero value keeps its default.

func (SlackExtraction) ContextBudget

func (e SlackExtraction) ContextBudget() int

func (SlackExtraction) ContextN

func (e SlackExtraction) ContextN() int

func (SlackExtraction) EscalateOver

func (e SlackExtraction) EscalateOver() int

func (SlackExtraction) GiveUpAfter

func (e SlackExtraction) GiveUpAfter() int

func (SlackExtraction) LanguageName

func (e SlackExtraction) LanguageName() string

func (SlackExtraction) MaxCallUSD

func (e SlackExtraction) MaxCallUSD() float64

func (SlackExtraction) MaxDayCalls

func (e SlackExtraction) MaxDayCalls() int

func (SlackExtraction) MaxDayUSD

func (e SlackExtraction) MaxDayUSD() float64

func (SlackExtraction) MaxWaitFor

func (e SlackExtraction) MaxWaitFor() time.Duration

func (SlackExtraction) On

func (e SlackExtraction) On() bool

func (SlackExtraction) QuietFor

func (e SlackExtraction) QuietFor() time.Duration

func (SlackExtraction) TierName

func (e SlackExtraction) TierName() string

func (SlackExtraction) Window

func (e SlackExtraction) Window() int

type SlackIngest

type SlackIngest struct {
	// Terms admit a message that holds one of them as a word, in any case.
	Terms []string `json:"terms"`
	// AllowApps and DenyApps hold bot ids (B...) or app ids (A...).
	AllowApps []string `json:"allow_apps"`
	DenyApps  []string `json:"deny_apps"`
	// Socket nil is on.
	Socket *bool `json:"socket"`
	// Since is the first start's backfill date, YYYY-MM-DD; empty is 7 days back.
	Since string `json:"since"`
}

SlackIngest is what the Slack source admits and how it listens.

func (SlackIngest) SocketOn

func (i SlackIngest) SocketOn() bool

type SlackTurns

type SlackTurns struct {
	// MaxChars bounds the unit's messages rendered into the instructions; zero is 30000, and less than MinSlackTurnChars reads as it.
	MaxChars int `json:"max_chars,omitempty"`
}

SlackTurns sets what a turn on a Slack unit reads.

func (SlackTurns) Chars

func (t SlackTurns) Chars() int

Jump to

Keyboard shortcuts

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