service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: Apache-2.0 Imports: 15 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 | printf "%.2f" }}
Credits: ${{ .CreditTotal | printf "%.2f" }}

Batches: {{ .BatchCount }}
Total Entries: {{ .EntryCount }}
`))
)
View Source
var (
	// DefaultFilenameTemplate is paygate'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-987654320.ach
	//  - 20191010-0830-987654320.ach.gpg (GPG encrypted)
	DefaultFilenameTemplate = `{{ date "20060102" }}-{{ date "1504" }}-{{ .RoutingNumber }}.ach{{ if .GPG }}.gpg{{ end }}`
)

Functions

func AwaitTermination

func AwaitTermination(logger log.Logger, terminationListener chan 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
	GPG       *GPG
}

func (*AuditTrail) Validate

func (cfg *AuditTrail) Validate() error

type AuditTrails

type AuditTrails []AuditTrail

func (AuditTrails) Validate

func (cfg AuditTrails) 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
	Consul        *consul.Config
	Admin         Admin
	Inbound       Inbound
	Shards        Shards
	Upload        UploadAgents
	Notifications Notifications
	AuditTrail    AuditTrails
	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

	Template    string
	CompanyName string
}

func (Email) Tmpl

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

type ErrorAlerting

type ErrorAlerting struct {
	PagerDuty *PagerDutyAlerting
	Mock      *MockAlerting
}

func (ErrorAlerting) Validate

func (n ErrorAlerting) 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) 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
}

type InMemory

type InMemory struct {
	URL string
}

type Inbound

type Inbound struct {
	HTTP  HTTPConfig
	InMem *InMemory
	Kafka *KafkaConfig
}

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
}

type Merging

type Merging struct {
	Directory      string
	FlattenBatches *FlattenBatches
}

type MockAgent

type MockAgent struct{}

type MockAlerting

type MockAlerting struct {
	Enabled bool
}

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 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
}

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
	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 Shards

type Shards []Shard

func (Shards) Validate

func (cfg Shards) Validate() error

type Signer

type Signer struct {
	KeyFile     string
	KeyPassword string
}

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 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

Jump to

Keyboard shortcuts

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