4c973b239fc3340e9983f06923b10a485303be2d
…
Go Cart Actor
A distributed cart management system using the actor model pattern.
Prerequisites
- Go 1.24.2+
- Protocol Buffers compiler (
protoc) - protoc-gen-go and protoc-gen-go-grpc plugins
Installing Protocol Buffers
On Windows:
winget install protobuf
On macOS:
brew install protobuf
On Linux:
# Ubuntu/Debian
sudo apt install protobuf-compiler
# Or download from: https://github.com/protocolbuffers/protobuf/releases
Installing Go protobuf plugin
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Working with Protocol Buffers
Generating Go code from proto files
After modifying any proto (proto/messages.proto, proto/cart_actor.proto, proto/control_plane.proto), regenerate the Go code (all three share the unified messages package):
cd proto
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
messages.proto cart_actor.proto control_plane.proto
Protocol Buffer Messages
The proto/messages.proto file defines the following message types:
AddRequest- Add items to cart (includes quantity, sku, country, optional storeId)SetCartRequest- Set entire cart contentsAddItem- Complete item information for cartRemoveItem- Remove item from cartChangeQuantity- Update item quantitySetDelivery- Configure delivery optionsSetPickupPoint- Set pickup locationPickupPoint- Pickup point detailsRemoveDelivery- Remove delivery optionCreateCheckoutOrder- Initiate checkoutOrderCreated- Order creation response
Building the project
go build .
Running tests
go test ./...
Important Notes
- Always regenerate protobuf Go code after modifying any
.protofiles (messages/cart_actor/control_plane) - The generated
messages.pb.gofile should not be edited manually - Make sure your PATH includes the protoc-gen-go binary location (usually
$GOPATH/bin)
Description
Languages
Go
95.9%
JavaScript
1.8%
Makefile
1.4%
Dockerfile
0.9%