Complete refactor to new grpc control plane and only http proxy for carts (#4)
Co-authored-by: matst80 <mats.tornberg@gmail.com> Reviewed-on: https://git.tornberg.me/mats/go-cart-actor/pulls/4 Co-authored-by: Mats Törnberg <mats@tornberg.me> Co-committed-by: Mats Törnberg <mats@tornberg.me>
This commit was merged in pull request #4.
This commit is contained in:
101
proto/control_plane.proto
Normal file
101
proto/control_plane.proto
Normal file
@@ -0,0 +1,101 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package messages;
|
||||
|
||||
option go_package = "git.tornberg.me/go-cart-actor/proto;messages";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Control Plane gRPC API
|
||||
// -----------------------------------------------------------------------------
|
||||
// Replaces the legacy custom frame-based control channel (previously port 1338).
|
||||
// Responsibilities:
|
||||
// - Liveness (Ping)
|
||||
// - Membership negotiation (Negotiate)
|
||||
// - Deterministic ring-based ownership (ConfirmOwner RPC removed)
|
||||
// - Actor ID listing for remote grain spawning (GetActorIds)
|
||||
// - Graceful shutdown notifications (Closing)
|
||||
// No authentication / TLS is defined initially (can be added later).
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Empty request placeholder (common pattern).
|
||||
message Empty {}
|
||||
|
||||
// Ping reply includes responding host and its current unix time (seconds).
|
||||
message PingReply {
|
||||
string host = 1;
|
||||
int64 unix_time = 2;
|
||||
}
|
||||
|
||||
// NegotiateRequest carries the caller's full view of known hosts (including self).
|
||||
message NegotiateRequest {
|
||||
repeated string known_hosts = 1;
|
||||
}
|
||||
|
||||
// NegotiateReply returns the callee's healthy hosts (including itself).
|
||||
message NegotiateReply {
|
||||
repeated string hosts = 1;
|
||||
}
|
||||
|
||||
// CartIdsReply returns the list of cart IDs (string form) currently owned locally.
|
||||
message ActorIdsReply {
|
||||
repeated uint64 ids = 1;
|
||||
}
|
||||
|
||||
// OwnerChangeAck retained as response type for Closing RPC (ConfirmOwner removed).
|
||||
message OwnerChangeAck {
|
||||
bool accepted = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
// ClosingNotice notifies peers this host is terminating (so they can drop / re-resolve).
|
||||
message ClosingNotice {
|
||||
string host = 1;
|
||||
}
|
||||
|
||||
// OwnershipAnnounce broadcasts first-touch ownership claims for cart IDs.
|
||||
// First claim wins; receivers SHOULD NOT overwrite an existing different owner.
|
||||
message OwnershipAnnounce {
|
||||
string host = 1; // announcing host
|
||||
repeated uint64 ids = 2; // newly claimed cart ids
|
||||
}
|
||||
|
||||
// ExpiryAnnounce broadcasts that a host evicted the provided cart IDs.
|
||||
message ExpiryAnnounce {
|
||||
string host = 1;
|
||||
repeated uint64 ids = 2;
|
||||
}
|
||||
|
||||
// ControlPlane defines cluster coordination and ownership operations.
|
||||
service ControlPlane {
|
||||
// Ping for liveness; lightweight health signal.
|
||||
rpc Ping(Empty) returns (PingReply);
|
||||
|
||||
// Negotiate merges host views; used during discovery & convergence.
|
||||
rpc Negotiate(NegotiateRequest) returns (NegotiateReply);
|
||||
|
||||
// GetCartIds lists currently owned cart IDs on this node.
|
||||
rpc GetLocalActorIds(Empty) returns (ActorIdsReply);
|
||||
|
||||
// ConfirmOwner RPC removed (was legacy ownership acknowledgement; ring-based ownership now authoritative)
|
||||
|
||||
// Ownership announcement: first-touch claim broadcast (idempotent; best-effort).
|
||||
rpc AnnounceOwnership(OwnershipAnnounce) returns (OwnerChangeAck);
|
||||
|
||||
// Expiry announcement: drop remote ownership hints when local TTL expires.
|
||||
rpc AnnounceExpiry(ExpiryAnnounce) returns (OwnerChangeAck);
|
||||
|
||||
// Closing announces graceful shutdown so peers can proactively adjust.
|
||||
rpc Closing(ClosingNotice) returns (OwnerChangeAck);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Generation Instructions:
|
||||
// protoc --go_out=. --go_opt=paths=source_relative \
|
||||
// --go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||
// control_plane.proto
|
||||
//
|
||||
// Future Enhancements:
|
||||
// - Add a streaming membership watch (server -> client) for immediate updates.
|
||||
// - Add TLS / mTLS for secure intra-cluster communication.
|
||||
// - Add richer health metadata (load, grain count) in PingReply.
|
||||
// -----------------------------------------------------------------------------
|
||||
1066
proto/messages.pb.go
1066
proto/messages.pb.go
File diff suppressed because it is too large
Load Diff
@@ -1,83 +1,77 @@
|
||||
syntax = "proto3";
|
||||
package messages;
|
||||
option go_package = ".;messages";
|
||||
option go_package = "git.tornberg.me/go-cart-actor/proto;messages";
|
||||
|
||||
message AddRequest {
|
||||
int32 quantity = 1;
|
||||
string sku = 2;
|
||||
string country = 3;
|
||||
optional string storeId = 4;
|
||||
}
|
||||
message ClearCartRequest {
|
||||
|
||||
message SetCartRequest {
|
||||
repeated AddRequest items = 1;
|
||||
}
|
||||
|
||||
message AddItem {
|
||||
int64 item_id = 1;
|
||||
int32 quantity = 2;
|
||||
int64 price = 3;
|
||||
int64 orgPrice = 9;
|
||||
string sku = 4;
|
||||
string name = 5;
|
||||
string image = 6;
|
||||
int32 stock = 7;
|
||||
int32 tax = 8;
|
||||
string brand = 13;
|
||||
string category = 14;
|
||||
string category2 = 15;
|
||||
string category3 = 16;
|
||||
string category4 = 17;
|
||||
string category5 = 18;
|
||||
string disclaimer = 10;
|
||||
string articleType = 11;
|
||||
string sellerId = 19;
|
||||
string sellerName = 20;
|
||||
string country = 21;
|
||||
optional string outlet = 12;
|
||||
optional string storeId = 22;
|
||||
uint32 item_id = 1;
|
||||
int32 quantity = 2;
|
||||
int64 price = 3;
|
||||
int64 orgPrice = 9;
|
||||
string sku = 4;
|
||||
string name = 5;
|
||||
string image = 6;
|
||||
int32 stock = 7;
|
||||
int32 tax = 8;
|
||||
string brand = 13;
|
||||
string category = 14;
|
||||
string category2 = 15;
|
||||
string category3 = 16;
|
||||
string category4 = 17;
|
||||
string category5 = 18;
|
||||
string disclaimer = 10;
|
||||
string articleType = 11;
|
||||
string sellerId = 19;
|
||||
string sellerName = 20;
|
||||
string country = 21;
|
||||
optional string outlet = 12;
|
||||
optional string storeId = 22;
|
||||
optional uint32 parentId = 23;
|
||||
}
|
||||
|
||||
message RemoveItem {
|
||||
int64 Id = 1;
|
||||
uint32 Id = 1;
|
||||
}
|
||||
|
||||
message ChangeQuantity {
|
||||
int64 id = 1;
|
||||
int32 quantity = 2;
|
||||
uint32 Id = 1;
|
||||
int32 quantity = 2;
|
||||
}
|
||||
|
||||
message SetDelivery {
|
||||
string provider = 1;
|
||||
repeated int64 items = 2;
|
||||
optional PickupPoint pickupPoint = 3;
|
||||
string country = 4;
|
||||
string zip = 5;
|
||||
optional string address = 6;
|
||||
optional string city = 7;
|
||||
string provider = 1;
|
||||
repeated uint32 items = 2;
|
||||
optional PickupPoint pickupPoint = 3;
|
||||
string country = 4;
|
||||
string zip = 5;
|
||||
optional string address = 6;
|
||||
optional string city = 7;
|
||||
}
|
||||
|
||||
message SetPickupPoint {
|
||||
int64 deliveryId = 1;
|
||||
string id = 2;
|
||||
optional string name = 3;
|
||||
optional string address = 4;
|
||||
optional string city = 5;
|
||||
optional string zip = 6;
|
||||
optional string country = 7;
|
||||
uint32 deliveryId = 1;
|
||||
string id = 2;
|
||||
optional string name = 3;
|
||||
optional string address = 4;
|
||||
optional string city = 5;
|
||||
optional string zip = 6;
|
||||
optional string country = 7;
|
||||
}
|
||||
|
||||
message PickupPoint {
|
||||
string id = 1;
|
||||
optional string name = 2;
|
||||
optional string address = 3;
|
||||
optional string city = 4;
|
||||
optional string zip = 5;
|
||||
optional string country = 6;
|
||||
string id = 1;
|
||||
optional string name = 2;
|
||||
optional string address = 3;
|
||||
optional string city = 4;
|
||||
optional string zip = 5;
|
||||
optional string country = 6;
|
||||
}
|
||||
|
||||
message RemoveDelivery {
|
||||
int64 id = 1;
|
||||
uint32 id = 1;
|
||||
}
|
||||
|
||||
message CreateCheckoutOrder {
|
||||
@@ -90,6 +84,33 @@ message CreateCheckoutOrder {
|
||||
}
|
||||
|
||||
message OrderCreated {
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
}
|
||||
|
||||
message Noop {
|
||||
// Intentionally empty - used for ownership acquisition or health pings
|
||||
}
|
||||
|
||||
message InitializeCheckout {
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
bool paymentInProgress = 3;
|
||||
}
|
||||
|
||||
message VoucherRule {
|
||||
string type = 2;
|
||||
string description = 3;
|
||||
string condition = 4;
|
||||
string action = 5;
|
||||
}
|
||||
|
||||
message AddVoucher {
|
||||
string code = 1;
|
||||
int64 value = 2;
|
||||
repeated VoucherRule voucherRules = 3;
|
||||
}
|
||||
|
||||
message RemoveVoucher {
|
||||
uint32 id = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user