Skip to content

Commit

Permalink
Add process events and event store
Browse files Browse the repository at this point in the history
Created new files for process events handling and event storage. The process events include timestamp and stream id and an interface for handling them. In addition, a new interface for event storage has been introduced.
  • Loading branch information
PiotrFerenc committed Jun 2, 2024
1 parent ded06ba commit 7c2af80
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/events/proces_events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package events

import (
"github.com/PiotrFerenc/mash2/internal/types"
"github.com/google/uuid"
"time"
)

type Event struct {
CreatedAt time.Time
StreamId uuid.UUID
}

type ProcessEvent interface {
ProcessEvent() *Event
}

type ProcessCreated struct {
Process types.Process
}

func (p ProcessCreated) ProcessEvent() *Event {
return &Event{
CreatedAt: time.Now(),
StreamId: p.Process.Id,
}
}
7 changes: 7 additions & 0 deletions internal/repositories/event-store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package repositories

import "github.com/PiotrFerenc/mash2/internal/events"

type EventStore interface {
AddEvent(event events.Event) error
}

0 comments on commit 7c2af80

Please sign in to comment.