github.com/mantzas/incata@v0.3.0/README.md (about)

     1  # incata [![alt text](https://godoc.org/github.com/mantzas/incata?status.png)](https://godoc.org/github.com/mantzas/incata) [![build status](https://img.shields.io/travis/mantzas/incata.svg)](http://travis-ci.org/mantzas/incata) [![Coverage Status](https://coveralls.io/repos/github/mantzas/incata/badge.svg?branch=master)](https://coveralls.io/github/mantzas/incata?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/mantzas/incata)](https://goreportcard.com/report/github.com/mantzas/incata)
     2  
     3  Event Sourcing Data Access Library
     4  
     5  Package incata is a source eventing data access library. The name combines incremental (inc) and data (ata).
     6  Details about event sourcing can be read on Martin Fowlers site(http://martinfowler.com/eaaDev/EventSourcing.html).
     7  
     8  Currently we support two relational DB's, MS Sql Server and Postgresql.
     9  
    10  The stored Event has the following structure:
    11  
    12      type Event struct {
    13        Id        int64
    14        SourceID  uuid.UUID
    15        Created   time.Time
    16        Payload   interface{}
    17        EventType string
    18        Version   int
    19      }
    20  
    21  The payload is the actual data that we like to store in our DB.
    22  Since the serializer can be anything the data type is set to interface{}.
    23  This means that our db table column for the Payload have to match the serializer's result data type.
    24  
    25  In order to use the appender or retriever we have to provide the following
    26  
    27  1. a serializer or deserializer which implements the Serializer or Deserializer interface or the .  A JSONMarshaller is provided.
    28  2. a writer or reader which implements the Writer or Reader interface. A SQLWriter and SQLReader is provided.
    29  3. a appender and retriever which implement the Appender and Retriever interface. Appender and Retriever are provided.
    30  
    31  The supported relational DB's are MS Sql Server and PostgreSQL.
    32  
    33  ###Check out the examples in the examples folder for setting up the default marshaller and reader/writers.
    34  
    35  ###MS SQL Server Setup
    36  
    37   SQL Server Driver used: 
    38   
    39      "github.com/denisenkom/go-mssqldb"
    40      
    41   DB Table setup (Provide a table name)
    42  
    43          CREATE TABLE {TableName} (
    44            Id BIGINT IDENTITY
    45            ,SourceId UNIQUEIDENTIFIER NOT NULL
    46            ,Created DATETIME2 NOT NULL
    47            ,EventType NVARCHAR(250) NOT NULL
    48            ,Version INT NOT NULL
    49            ,Payload NVARCHAR(MAX) NOT NULL
    50            ,CONSTRAINT PK_Event PRIMARY KEY CLUSTERED (Id)
    51          ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    52  
    53           GO
    54  
    55           CREATE INDEX IX_Event_SourceId
    56           ON {TableName} (SourceId)
    57           ON [PRIMARY]
    58           GO
    59  
    60  ### PostgreSQL Setup
    61           
    62  PostgreSQL Driver used:
    63      
    64      "github.com/lib/pq" 
    65  
    66  DB Table setup (Provide a table name)
    67  
    68        CREATE TABLE {TableName}
    69        (
    70         "Id" serial NOT NULL,
    71         "SourceId" uuid,
    72         "Created" timestamp without time zone,
    73         "EventType" character varying(250),
    74         "Version" integer,
    75         "Payload" text,
    76         CONSTRAINT "PK_Event" PRIMARY KEY ("Id")
    77        )
    78        WITH (
    79         OIDS=FALSE
    80        );
    81  
    82        CREATE INDEX "event_idx_sourceId"
    83         ON {TableName}
    84         USING btree
    85         ("SourceId");