pgpublish

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2017 License: Apache-2.0 Imports: 14 Imported by: 2

README

pgpublish

Publish events from Postgres to an SNS topic

CircleCI

This project complements the pgeventstore project to take events from the publish table and send them to an AWS SNS topic. Once published to SNS, events are removed from the publish table.

Dependencies

go get github.com/xtracdev/pgconn
go get github.com/xtracdev/pgeventstore
go get github.com/xtracdev/goes
go get github.com/Sirupsen/logrus
go get github.com/gucumber/gucumber
go get github.com/stretchr/testify/assert
go get github.com/lib/pq
go get github.com/aws/aws-sdk-go/...
go get github.com/armon/go-metrics

Contributing

To contribute, you must certify you agree with the Developer Certificate of Origin by signing your commits via git -s. To create a signature, configure your user name and email address in git. Sign with your real name, do not use pseudonyms or submit anonymous commits.

In terms of workflow:

  1. For significant changes or improvement, create an issue before commencing work.
  2. Fork the respository, and create a branch for your edits.
  3. Add tests that cover your changes, unit tests for smaller changes, acceptance test for more significant functionality.
  4. Run gofmt on each file you change before committing your changes.
  5. Run golint on each file you change before committing your changes.
  6. Make sure all the tests pass before committing your changes.
  7. Commit your changes and issue a pull request.

License

(c) 2017 Fidelity Investments Licensed under the Apache License, Version 2.0

Documentation

Index

Constants

View Source
const (
	TopicARN            = "TOPIC_ARN"
	LogLevel            = "PG_PUBLISH_LOG_LEVEL"
	MetricsDumpInterval = 1 * time.Minute
	PublishEnabled      = "PG_PUBLISH_ENABLED"
)

Variables

View Source
var (
	ErrDecodingEvent = errors.New("Error Decoding PG Event")
)

Functions

func CheckTopic

func CheckTopic(svc *sns.SNS, arn string) error

func DecodePGEvent

func DecodePGEvent(encoded string) (aggId string, version int, payload []byte, typecode string, timestamp time.Time, err error)

func EncodePGEvent

func EncodePGEvent(aggId string, version int, payload []byte, typecode string, timestamp time.Time) string

func PublishEvents

func PublishEvents(publisher *EventStorePublisher)

func SetLogLevel

func SetLogLevel(logLevelEnvVarName string, env *envinject.InjectedEnv) error

SetLogLevel sets the log level reading the level to use from the envrionment using the given environment variable name

Types

type Event2Publish

type Event2Publish struct {
	AggregateId string
	Version     int
	Typecode    string
	Payload     []byte
	Timestamp   time.Time
}

type EventStorePublisher

type EventStorePublisher struct {
	// contains filtered or unexported fields
}

func NewEvents2Pub

func NewEvents2Pub(db *sql.DB, topicARN string, publishEnabled bool) (*EventStorePublisher, error)

func (*EventStorePublisher) AggsWithEvents

func (e2p *EventStorePublisher) AggsWithEvents() ([]Event2Publish, error)

func (*EventStorePublisher) GetTableLock

func (e2p *EventStorePublisher) GetTableLock() (bool, error)

func (*EventStorePublisher) InitMetricsSink

func (e2p *EventStorePublisher) InitMetricsSink()

func (*EventStorePublisher) PublishEvent

func (e2p *EventStorePublisher) PublishEvent(e2pub *Event2Publish) error

func (*EventStorePublisher) ReleaseTableLock

func (e2p *EventStorePublisher) ReleaseTableLock() error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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