pqstream

package module
v0.0.0-...-c563a86 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 12 Imported by: 0

README

pqstream

Postgres-backed Event Library for Go

TODO

  • Improve docs (about considerations, setup example, if pqstream works across sessions etc)
  • Better logging, possibly with an optional Zerolog adapter
  • Authorization hooks for subscription which provide access to the http req, res, and the topic requested in order to allow or block access to a topic list
  • Better configurability? Different encoders (Msgpack, Protobuf etc)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustPublishEvent

func MustPublishEvent(ctx context.Context, db *sql.DB, topic string, payload map[string]interface{})

func PublishEvent

func PublishEvent(ctx context.Context, db *sql.DB, topic string, payload map[string]interface{}) error

Types

type Event

type Event struct {
	ID        string                 `json:"id"`
	Topic     string                 `json:"topic"`
	Payload   map[string]interface{} `json:"payload"`
	CreatedAt time.Time              `json:"created_at"`
}

type EventstreamHandler

type EventstreamHandler struct {
	PostgreSQLConnectionString string
}

func (EventstreamHandler) ServeHTTP

func (e EventstreamHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)

type Subscription

type Subscription struct {
	C <-chan Event
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription(ctx context.Context, postgresConnectionConfig string, topics ...string) (Subscription, error)

func (Subscription) Cancel

func (e Subscription) Cancel()

Jump to

Keyboard shortcuts

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