service

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultEmailTemplate = template.Must(template.New("email").Parse(`
A file has been {{ .Verb }}ed{{ if .Hostname }}{{ if eq .Verb "upload" }} to{{ else }} from{{end}} {{ .Hostname }}{{end}} - {{ .Filename }}
Name: {{ .CompanyName }}
Debits:  ${{ .DebitTotal }}
Credits: ${{ .CreditTotal }}

Batches: {{ .BatchCount }}
Total Entries: {{ .EntryCount }}
`))
)
View Source
var (
	// DefaultFilenameTemplate is achgateway's standard filename format for ACH files which are uploaded to an ODFI
	//
	// The format consists of a few parts: "year month day" timestamp, "hour minute" timestamp, and routing number
	//
	// Examples:
	//  - 20191010-0830-LiveODFI.ach      (.ShardName of "LiveODFI")
	//  - 20191010-0830-987654320.ach
	//  - 20191010-0830-987654320.ach.gpg (GPG encrypted)
	DefaultFilenameTemplate = `{{ date "20060102" }}-{{ date "150405" }}-{{ .RoutingNumber }}.ach{{ if .GPG }}.gpg{{ end }}`
)

Functions

func AwaitTermination

func AwaitTermination(logger log.Logger, terminationListener chan error) error

func NewInternalClient

func NewInternalClient(logger log.Logger, config *ClientConfig, name string) *http.Client

func NewTerminationListener

func NewTerminationListener() chan error

Types

type Admin

type Admin struct {
	BindAddress string
}

func (Admin) Validate

func (cfg Admin) Validate() error

type AuditTrail

type AuditTrail struct {
	ID        string
	BucketURI string
	BasePath  string // e.g. 'incoming' or 'outgoing'
	GPG       *GPG
}

func (*AuditTrail) Validate

func (cfg *AuditTrail) Validate() error

type ClientConfig

type ClientConfig struct {
	Timeout             time.Duration
	MaxIdleConns        int
	MaxIdleConnsPerHost int
	MaxConnsPerHost     int
}

type Config

type Config struct {
	Logger    log.Logger `json:"-"`
	Clients   *ClientConfig
	Database  database.DatabaseConfig
	Telemetry telemetry.Config
	Admin     Admin
	Inbound   Inbound
	Events    *EventsConfig
	Sharding  Sharding
	Upload    UploadAgents
	Errors    ErrorAlerting
}

func (*Config) Validate

func (cfg *Config) Validate() error

type Cutoffs

type Cutoffs struct {
	Timezone string
	Windows  []string
}

func (Cutoffs) Location

func (cfg Cutoffs) Location() *time.Location

func (Cutoffs) Validate

func (cfg Cutoffs) Validate() error

type Email

type Email struct {
	ID string

	From string
	To   []string

	// ConnectionURI is a URI used to connect with a remote SFTP server.
	// This config typically needs to contain enough values to successfully
	// authenticate with the server.
	// - insecure_skip_verify is an optional parameter for disabling certificate verification
	//
	// Example: smtps://user:pass@localhost:1025/?insecure_skip_verify=true
	ConnectionURI string
	MaxRetries    int

	Template    string
	CompanyName string
}

func (Email) Tmpl

func (cfg Email) Tmpl() *template.Template

type ErrorAlerting

type ErrorAlerting struct {
	PagerDuty *PagerDutyAlerting
	Slack     *SlackAlerting
}

func (ErrorAlerting) Validate

func (n ErrorAlerting) Validate() error

type EventsConfig added in v0.2.0

type EventsConfig struct {
	Stream    *EventsStream
	Webhook   *WebhookConfig
	Transform *models.TransformConfig
}

func (*EventsConfig) Validate added in v0.3.0

func (cfg *EventsConfig) Validate() error

type EventsStream added in v0.3.0

type EventsStream struct {
	InMem *InMemory
	Kafka *KafkaConfig
}

func (*EventsStream) Validate added in v0.3.0

func (cfg *EventsStream) Validate() error

type FTP

type FTP struct {
	Hostname string
	Username string
	Password string

	CAFilepath   string
	DialTimeout  time.Duration
	DisabledEPSV bool
}

func (*FTP) CAFile

func (cfg *FTP) CAFile() string

func (*FTP) DisableEPSV

func (cfg *FTP) DisableEPSV() bool

func (*FTP) MarshalJSON added in v0.6.3

func (cfg *FTP) MarshalJSON() ([]byte, error)

func (*FTP) String

func (cfg *FTP) String() string

func (*FTP) Timeout

func (cfg *FTP) Timeout() time.Duration

type FlattenBatches

type FlattenBatches struct{}

type GPG

type GPG struct {
	KeyFile string
	Signer  *Signer
}

type GlobalConfig

type GlobalConfig struct {
	ACHGateway Config
}

type HTTPConfig

type HTTPConfig struct {
	BindAddress string
	TLS         TLSConfig

	Transform    *models.TransformConfig
	MaxBodyBytes int64
}

type InMemory

type InMemory struct {
	URL string
}

func (*InMemory) Validate added in v0.3.0

func (cfg *InMemory) Validate() error

type Inbound

type Inbound struct {
	HTTP  HTTPConfig
	InMem *InMemory
	Kafka *KafkaConfig
	ODFI  *ODFIFiles
	Audit *AuditTrail
}

func (Inbound) Validate

func (cfg Inbound) Validate() error

type KafkaConfig

type KafkaConfig struct {
	Brokers []string
	Key     string
	Secret  string
	Group   string
	Topic   string
	TLS     bool

	// AutoCommit in Sarama refers to "automated publishing of consumer offsets
	// to the broker" rather than a Kafka broker's meaning of "commit consumer
	// offsets on read" which leads to "at-most-once" delivery.
	AutoCommit bool

	Consumer KafkaConsumerConfig
	Producer KafkaProducerConfig

	Transform *models.TransformConfig
}

func (*KafkaConfig) Validate added in v0.3.0

func (cfg *KafkaConfig) Validate() error

type KafkaConsumerConfig added in v0.20.0

type KafkaConsumerConfig struct{}

KafkaConsumerConfig represents config options from sarama's Config.Consumer type. When these fields are non-zero values they will be set on the pubsub Subscription

type KafkaProducerConfig added in v0.20.0

type KafkaProducerConfig struct {
	MaxMessageBytes int
}

KafkaProducerConfig represents config options from sarama's Config.Producer type. When these fields are non-zero values they will be set on the pubsub Topic

type MergableConfig added in v0.15.0

type MergableConfig struct {
	Conditions     *ach.Conditions
	FlattenBatches *FlattenBatches

	MergeInGroupsOf int
}

type Merging

type Merging struct {
	Storage   storage.Config
	Directory string // fallback config for Storage.Filesystem.Directory
}

type MockAgent

type MockAgent struct{}

type NotificationRetries

type NotificationRetries struct {
	Interval   time.Duration
	MaxRetries uint64
}

type Notifications

type Notifications struct {
	Email     []Email
	PagerDuty []PagerDuty
	Slack     []Slack
	Retry     *NotificationRetries
}

func (Notifications) FindEmails

func (cfg Notifications) FindEmails(ids []string) []Email

func (Notifications) FindPagerDutys

func (cfg Notifications) FindPagerDutys(ids []string) []PagerDuty

func (Notifications) FindSlacks

func (cfg Notifications) FindSlacks(ids []string) []Slack

func (Notifications) Validate

func (cfg Notifications) Validate() error

type ODFICorrections added in v0.3.0

type ODFICorrections struct {
	Enabled     bool
	PathMatcher string
}

type ODFIFiles added in v0.3.0

type ODFIFiles struct {
	Processors ODFIProcessors
	Interval   time.Duration
	ShardNames []string
	Storage    ODFIStorage
	Audit      *AuditTrail
}

func (*ODFIFiles) Validate added in v0.3.0

func (cfg *ODFIFiles) Validate() error

type ODFIIncoming added in v0.16.0

type ODFIIncoming struct {
	Enabled     bool
	PathMatcher string

	ExcludeCorrections     bool
	ExcludePrenotes        bool
	ExcludeReturns         bool
	ExcludeReconciliations bool
}

type ODFIPrenotes added in v0.3.0

type ODFIPrenotes struct {
	Enabled     bool
	PathMatcher string
}

type ODFIProcessors added in v0.3.0

type ODFIProcessors struct {
	Corrections    ODFICorrections
	Incoming       ODFIIncoming
	Reconciliation ODFIReconciliation
	Prenotes       ODFIPrenotes
	Returns        ODFIReturns

	Validation ach.ValidateOpts
}

func (ODFIProcessors) Validate added in v0.3.0

func (cfg ODFIProcessors) Validate() error

type ODFIReconciliation added in v0.3.0

type ODFIReconciliation struct {
	Enabled     bool
	PathMatcher string

	ProduceFileEvents  bool
	ProduceEntryEvents bool
}

type ODFIReturns added in v0.3.0

type ODFIReturns struct {
	Enabled     bool
	PathMatcher string
}

type ODFIStorage added in v0.3.0

type ODFIStorage struct {
	// Directory is the local filesystem path for downloading files into
	Directory string

	// CleanupLocalDirectory determines if we delete the local directory after
	// processing is finished. Leaving these files around helps debugging, but
	// also exposes customer information.
	CleanupLocalDirectory bool

	// KeepRemoteFiles determines if we delete the remote file on an ODFI's server
	// after downloading and processing of each file.
	KeepRemoteFiles bool

	// RemoveZeroByteFiles determines if we should delete files that are zero bytes
	RemoveZeroByteFiles bool
}

type Output

type Output struct {
	Format string
}

func (*Output) Validate

func (cfg *Output) Validate() error

type PagerDuty

type PagerDuty struct {
	ID         string
	ApiKey     string
	From       string
	ServiceKey string
}

func (PagerDuty) Validate

func (cfg PagerDuty) Validate() error

type PagerDutyAlerting

type PagerDutyAlerting struct {
	ApiKey string

	// To send an alert event we need to provide the value of
	// the Integration Key (add API integration to service in PD to get it)
	// as RoutingKey
	RoutingKey string
}

func (PagerDutyAlerting) Validate

func (cfg PagerDutyAlerting) Validate() error

type PreUpload

type PreUpload struct {
	GPG *GPG
}

func (*PreUpload) Validate

func (cfg *PreUpload) Validate() error

type SFTP

type SFTP struct {
	Hostname string
	Username string

	Password         string
	ClientPrivateKey string
	HostPublicKey    string

	DialTimeout           time.Duration
	MaxConnectionsPerFile int
	MaxPacketSize         int

	// SkipDirectoryCreation will configure achgateway to create
	// directories on the remote server prior to uploading files.
	SkipDirectoryCreation bool
}

func (*SFTP) MarshalJSON added in v0.6.3

func (cfg *SFTP) MarshalJSON() ([]byte, error)

func (*SFTP) MaxConnections

func (cfg *SFTP) MaxConnections() int

func (*SFTP) PacketSize

func (cfg *SFTP) PacketSize() int

func (*SFTP) String

func (cfg *SFTP) String() string

func (*SFTP) Timeout

func (cfg *SFTP) Timeout() time.Duration

type Shard

type Shard struct {
	Name                     string
	Cutoffs                  Cutoffs
	PreUpload                *PreUpload
	UploadAgent              string
	Mergable                 MergableConfig
	OutboundFilenameTemplate string
	Output                   *Output
	Notifications            *Notifications
	Audit                    *AuditTrail
}

func (*Shard) FilenameTemplate

func (cfg *Shard) FilenameTemplate() string

func (Shard) Validate

func (cfg Shard) Validate() error

type ShardMapping added in v0.11.0

type ShardMapping struct {
	ShardKey  string
	ShardName string
}

func (*ShardMapping) Validate added in v0.11.0

func (m *ShardMapping) Validate() error

type Sharding added in v0.3.0

type Sharding struct {
	Shards   []Shard
	Mappings []ShardMapping
	Default  string
}

func (Sharding) Find added in v0.3.0

func (cfg Sharding) Find(name string) *Shard

func (Sharding) Validate added in v0.3.0

func (cfg Sharding) Validate() error

type Signer

type Signer struct {
	KeyFile     string
	KeyPassword string
}

func (*Signer) MarshalJSON added in v0.6.3

func (cfg *Signer) MarshalJSON() ([]byte, error)

func (*Signer) Password

func (cfg *Signer) Password() string

type Slack

type Slack struct {
	ID string

	WebhookURL string
}

func (Slack) Validate

func (cfg Slack) Validate() error

type SlackAlerting added in v0.16.0

type SlackAlerting struct {
	// Oauth 2.0 access tokens are generated manually when creating a slack app
	// https://api.slack.com/authentication/token-types
	AccessToken string

	// A default channel can be specified when creating a Slack app, and this config
	// can override or be used as the default
	ChannelID string
}

func (SlackAlerting) Validate added in v0.16.0

func (cfg SlackAlerting) Validate() error

type TLSConfig added in v0.6.2

type TLSConfig struct {
	// CertFile points to a filename containing an X.509 certificate chain usable to
	// wrap HTTP connections with TLS.
	CertFile string

	// KeyFile points to a filename containing a matching private key for encrypting
	// and signing TLS connections found in CertFile.
	KeyFile string
}

TLSConfig specifies filepaths where a TLS certificate chain and private key can be found.

type UploadAgent

type UploadAgent struct {
	ID            string
	FTP           *FTP
	SFTP          *SFTP
	Mock          *MockAgent
	Paths         UploadPaths
	Notifications *UploadNotifiers

	// AllowedIPs is a comma separated list of IP addresses and CIDR ranges
	// where connections are allowed. If this value is non-empty remote servers
	// not within these ranges will not be connected to.
	AllowedIPs string
}

func (*UploadAgent) SplitAllowedIPs

func (cfg *UploadAgent) SplitAllowedIPs() []string

type UploadAgents

type UploadAgents struct {
	Agents         []UploadAgent
	Merging        Merging
	Retry          *UploadRetry
	DefaultAgentID string
}

func (UploadAgents) Find

func (ua UploadAgents) Find(id string) *UploadAgent

func (UploadAgents) Validate

func (ua UploadAgents) Validate() error

type UploadNotifiers

type UploadNotifiers struct {
	Email     []string
	PagerDuty []string
	Slack     []string
}

type UploadPaths

type UploadPaths struct {
	Inbound        string
	Outbound       string
	Reconciliation string
	Return         string
}

type UploadRetry

type UploadRetry struct {
	Interval   time.Duration
	MaxRetries uint64
}

func (*UploadRetry) Validate

func (cfg *UploadRetry) Validate() error

type WebhookConfig added in v0.2.0

type WebhookConfig struct {
	Endpoint string
}

func (*WebhookConfig) Validate added in v0.3.0

func (cfg *WebhookConfig) Validate() error

Jump to

Keyboard shortcuts

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