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