Skip to content

Configuration file keys

Every options struct in Patrol carries json, yaml and toml tags, so the same struct loads from any of the three formats and the library itself does no config loading. You decode the file; you pass the struct to the constructor.

The tables below are generated from the library’s exported API, 33 keys across 9 structs. A field whose tag is - is a function or a callback: it never comes from a file and is set in code.

Note that the JSON and the YAML spellings differ. JSON uses snake_case, YAML and TOML use the Go field name. That is the tag as written in the library, not a choice made here.

The batching itself. patrol.NewProducer(opts, flushers...), documented on Producer and batching.

FieldGo typeJSONYAMLTOML
BufferIntervaltime.Durationbuffer_intervalBufferIntervalBufferInterval
MaxBatchSizeintmax_batch_sizeMaxBatchSizeMaxBatchSize
MergeWindowtime.Durationmerge_windowMergeWindowMergeWindow
OnErrorfunc(err error)set in codeset in codeset in code
ProjectNamestringproject_nameProjectNameProjectName

patrol.NewSlack(opts, clientOpts...). Token and Channels are required. See Slack.

FieldGo typeJSONYAMLTOML
AcceptChannelEventfunc(channel string, e *Event) boolset in codeset in codeset in code
Channels[]stringchannelsChannelsChannels
TokenstringtokenTokenToken

patrol.NewDiscord(opts). BotToken and Channels are required. See Discord.

FieldGo typeJSONYAMLTOML
BotTokenstringbot_tokenBotTokenBotToken
Channels[]stringchannelsChannelsChannels
TimeZonestringtime_zoneTimeZoneTimeZone

patrol.NewTwilio(opts). All four of AccountSID, AuthToken, FromNumber and ToNumber are required. See Twilio.

FieldGo typeJSONYAMLTOML
AccountSIDstringaccount_sidAccountSIDAccountSID
AuthTokenstringauth_tokenAuthTokenAuthToken
FromNumberstringfrom_numberFromNumberFromNumber
TimeZonestringtime_zoneTimeZoneTimeZone
ToNumberstringto_numberToNumberToNumber

patrol.NewInbox(opts), the SMTP email flusher. From, To, Host and Port are required. See Email.

FieldGo typeJSONYAMLTOML
FromstringfromFromFrom
FromPasswordstringfrom_passwordFromPasswordFromPassword
HoststringhostHostHost
PortintportPortPort
TimeZonestringtime_zoneTimeZoneTimeZone
To[]stringtoToTo

patrol.NewSQL(ctx, opts). Engine is required, and it also decides the placeholder style. See SQL.

FieldGo typeJSONYAMLTOML
DSNstringdsnDSNDSN
EnginestringengineEngineEngine

patrol.NewClient(opts, clientOpts...), which posts batches to a Server. Nothing is validated here: the constructor returns no error. See HTTP client.

FieldGo typeJSONYAMLTOML
BaseURLstringbase_urlBaseURLBaseURL
BasicAuthBasicAuthOptionsbasic_authBasicAuthBasicAuth
TokenstringtokenTokenToken

The nested struct behind ClientOptions.BasicAuth. In a YAML file it is a block under BasicAuth.

FieldGo typeJSONYAMLTOML
PasswordstringpasswordPasswordPassword
UsernamestringusernameUsernameUsername

patrol.NewServer(opts, flushers...). Nothing is required, which means an unconfigured server accepts every request. See Run your own Server.

FieldGo typeJSONYAMLTOML
BasicAuthmap[string]stringbasic_authBasicAuthBasicAuth
ConsumeTimeouttime.Durationconsume_timeoutConsumeTimeoutConsumeTimeout
OnErrorfunc(err error)set in codeset in codeset in code
Tokens[]stringtokensTokensTokens

One YAML file per integration is what the library’s own _examples/basic/program does, and it is the shape these keys are built for:

# slack.yml
Token: xoxb-your-bot-token
Channels:
- C0123456789
# inbox.yml
From: alerts@example.com
FromPassword: your_app_password
To:
- oncall@example.com
Host: smtp.example.com
Port: 587
TimeZone: Europe/Athens

Decode each one into its options struct and hand it to its constructor. The library ships no config loader on purpose: your service already has one, and it already knows where your secrets come from.

scripts/gen-config-keys.mjs reads .claude/api-surface.txt in the library’s own repository, which that project’s build regenerates and refuses to let drift from the code. A tag change there shows up as a stale generated file here and fails this site’s build before it can ship a key name that does not exist.