Skip to content
Event Sourcing Data Access Library
Go
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples added created time in event Jun 26, 2016
marshal removed failing test Aug 17, 2016
mocks finaly moved to ginkgo Mar 3, 2016
model added created time in event Jun 26, 2016
reader Fixed broken tests Feb 28, 2018
storage Fixed broken tests Feb 28, 2018
vendor Travis to 1.9.x and used dep Feb 28, 2018
writer added created time in event Jun 26, 2016
.gitignore removed vendor entry Aug 10, 2016
.travis.yml Travis to 1.9.x and used dep Feb 28, 2018
Gopkg.lock Travis to 1.9.x and used dep Feb 28, 2018
Gopkg.toml Travis to 1.9.x and used dep Feb 28, 2018
LICENSE initial commit Jan 23, 2016
README.md fixed read me Jul 24, 2016
appender.go changed interface arguemnt Jun 4, 2016
appender_test.go added created time in event Jun 26, 2016
debug.log added glide vendor Feb 21, 2017
doc.go golint fix Feb 16, 2016
incata_suite_test.go migrating to ginkgo Mar 3, 2016
retriever.go Fixed broken tests Feb 28, 2018
retriever_test.go Fixed broken tests Feb 28, 2018

README.md

incata alt text build status Coverage Status Go Report Card

Event Sourcing Data Access Library

Package incata is a source eventing data access library. The name combines incremental (inc) and data (ata). Details about event sourcing can be read on Martin Fowlers site.

Currently we support two relational DB's, MS Sql Server and Postgresql.

The stored Event has the following structure:

type Event struct {
  Id        int64
  SourceID  uuid.UUID
  Created   time.Time
  Payload   interface{}
  EventType string
  Version   int
}

The payload is the actual data that we like to store in our DB. Since the serializer can be anything the data type is set to interface{}. This means that our db table column for the Payload have to match the serializer's result data type.

In order to use the appender or retriever we have to provide the following

  • A serializer or deserializer which implements the Serializer or Deserializer interface or the . A JSONMarshaller is provided.
  • A writer or reader which implements the Writer or Reader interface. A SQLWriter and SQLReader is provided.
  • A appender and retriever which implement the Appender and Retriever interface. Appender and Retriever are provided.

The supported relational DB's are MS Sql Server and PostgreSQL.

Check out the examples in the examples folder for setting up the default marshaller and reader/writers

MS SQL Server Setup

SQL Server Driver used:

"github.com/denisenkom/go-mssqldb"

DB Table setup (Provide a table name)

    CREATE TABLE {TableName} (
      Id BIGINT IDENTITY
      ,SourceId UNIQUEIDENTIFIER NOT NULL
      ,Created DATETIME2 NOT NULL
      ,EventType NVARCHAR(250) NOT NULL
      ,Version INT NOT NULL
      ,Payload NVARCHAR(MAX) NOT NULL
      ,CONSTRAINT PK_Event PRIMARY KEY CLUSTERED (Id)
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

     GO

     CREATE INDEX IX_Event_SourceId
     ON {TableName} (SourceId)
     ON [PRIMARY]
     GO

PostgreSQL Setup

PostgreSQL Driver used:

"github.com/lib/pq"

DB Table setup (Provide a table name)

  CREATE TABLE {table_name}
  (
    id bigserial NOT NULL,
    source_id uuid NOT NULL,
    created timestamp with time zone NOT NULL,
    event_type character varying(250) NOT NULL,
    version integer NOT NULL,
    payload text NOT NULL,
    CONSTRAINT pk_{table_name}_id PRIMARY KEY (id)
  )
  WITH (
    OIDS=FALSE
  );

  CREATE INDEX ix_order_event_source_id
    ON {table_name}
    USING btree
    (source_id);
You can’t perform that action at this time.