yehohanan7 / flux Goto Github PK
View Code? Open in Web Editor NEWA simple CQRS Framework for go
License: MIT License
A simple CQRS Framework for go
License: MIT License
Hi all, I've started playing around with the framework and found it nicely structured.
I'm having some difficulties on a rookie implementation. When my aggregate handle the event, the aggregate property loose its value. Any idea why?
Any help will be much appreciated. :)
The code:
package main
import (
"fmt"
"github.com/satori/go.uuid"
"github.com/yehohanan7/flux"
"github.com/yehohanan7/flux/cqrs"
)
//Object
type InventoryItem struct {
cqrs.Aggregate
Activated bool
}
func (ii *InventoryItem) Deactivate() error {
if !ii.Activated {
return fmt.Errorf("InventoryItem already deactivated")
}
ii.Update(InventoryItemDeactivated{}) //-> Trigger the Handle deactivated...
//---> Activated is True
return nil
}
//Events
type InventoryItemCreated struct {
Id string
}
type InventoryItemDeactivated struct {
}
//Event handlers
func (ii *InventoryItem) HandleInventoryItemCreated(event InventoryItemCreated) {
ii.Id = event.Id
ii.Activated = true
}
func (ii *InventoryItem) HandleInventoryItemDeactivated(event InventoryItemDeactivated) {
ii.Activated = false
// --> Event is handled while doing the update and Activated properly set to False
}
func NewInventoryItem(id uuid.UUID) InventoryItem {
inventoryItem := new(InventoryItem)
var aggregateId = id.String()
inventoryItem.Aggregate = cqrs.NewAggregate(aggregateId, inventoryItem, store)
inventoryItem.Update(InventoryItemCreated{aggregateId})
return *inventoryItem
}
var store = flux.NewMemoryStore()
func main() {
inventoryItem := NewInventoryItem(uuid.NewV4())
// Activated is true...
inventoryItem.Deactivate()
//Activated is true...
inventoryItem.Save()
// Activated is True...
fmt.Println(inventoryItem.Activated)
}
Rafty to the rescue ?
I did the same thing with boltdb, raft and serf.
I want to use aggregate
and consumer
to implement process manager. Can I add this feature to flux? Or I should do this in a separate repository to keep the project simple.
Hi, sorry for the newbie question, but which software do you use to run the requests specified in client.http file? I saw that there was a package for emacs, but I'm wondering if there is any mac/homebrew app that performs these tasks?
Thanks,
Marcos
Ledisdb is more suitable for flux as it supports various data structures like List, Hash & Set etc.
I like the simple offset mechanism.
The boltdb stores also, as it's seamless to get going.
I am glad a cqrs system like this is being setup and could help.
I don't get why the readme says it's all about not needing Kafka and the roadmap says it will be incorporated.
I would like to see this design allow running everything in a single application, whilst using drivers to easily flip the system into a multi server solution. This is becoming pretty doable. I am on mobile right now but can send you some links later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.