80 lines
1.7 KiB
Markdown
80 lines
1.7 KiB
Markdown
# 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 plugin
|
|
|
|
### Installing Protocol Buffers
|
|
|
|
On Windows:
|
|
```powershell
|
|
winget install protobuf
|
|
```
|
|
|
|
On macOS:
|
|
```bash
|
|
brew install protobuf
|
|
```
|
|
|
|
On Linux:
|
|
```bash
|
|
# Ubuntu/Debian
|
|
sudo apt install protobuf-compiler
|
|
|
|
# Or download from: https://github.com/protocolbuffers/protobuf/releases
|
|
```
|
|
|
|
### Installing Go protobuf plugin
|
|
|
|
```bash
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
```
|
|
|
|
## Working with Protocol Buffers
|
|
|
|
### Generating Go code from proto files
|
|
|
|
After modifying `proto/messages.proto`, regenerate the Go code:
|
|
|
|
```bash
|
|
cd proto
|
|
protoc --go_out=. --go_opt=paths=source_relative messages.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 contents
|
|
- `AddItem` - Complete item information for cart
|
|
- `RemoveItem` - Remove item from cart
|
|
- `ChangeQuantity` - Update item quantity
|
|
- `SetDelivery` - Configure delivery options
|
|
- `SetPickupPoint` - Set pickup location
|
|
- `PickupPoint` - Pickup point details
|
|
- `RemoveDelivery` - Remove delivery option
|
|
- `CreateCheckoutOrder` - Initiate checkout
|
|
- `OrderCreated` - Order creation response
|
|
|
|
### Building the project
|
|
|
|
```bash
|
|
go build .
|
|
```
|
|
|
|
### Running tests
|
|
|
|
```bash
|
|
go test ./...
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
- Always regenerate protobuf Go code after modifying `.proto` files
|
|
- The generated `messages.pb.go` file should not be edited manually
|
|
- Make sure your PATH includes the protoc-gen-go binary location (usually `$GOPATH/bin`) |