mirror of
https://github.com/hexolan/stocklet.git
synced 2026-03-26 11:41:18 +00:00
fix: misspell
docs: add reference to conventional commit messages corrections: * `AVALIABLE` -> `AVAILABLE` * `UNAVALIABLE` -> `UNAVAILABLE` * `succesful` -> `successful`
This commit is contained in:
@@ -13,6 +13,8 @@ The code has been formatted using [`gofmt`](https://pkg.go.dev/cmd/gofmt).
|
||||
|
||||
The protobuf schema files have been formatted using [`buf format`](https://buf.build/docs/reference/cli/buf/format).
|
||||
|
||||
The markdown files have been linted and formatted using [markdownlint](https://github.com/DavidAnson/markdownlint).
|
||||
The markdown files have been linted and formatted using [markdownlint](https://github.com/DavidAnson/markdownlint) (with the exception of MD013).
|
||||
|
||||
I used [PlantUML](https://plantuml.com/) as the tool to help make the diagrams. The PlantUML files are avaliable alongside the resulting images: [`/docs/imgs/overview.plantuml`](/docs/imgs/overview.plantuml) and [`/docs/imgs/placeordersaga.plantuml`](/docs/imgs/placeordersaga.plantuml)
|
||||
Commit messages should adhere to the [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) specification.
|
||||
|
||||
I used [PlantUML](https://plantuml.com/) as the tool to help make the diagrams. The PlantUML files are available alongside the resulting images: [`/docs/imgs/overview.plantuml`](/docs/imgs/overview.plantuml) and [`/docs/imgs/placeordersaga.plantuml`](/docs/imgs/placeordersaga.plantuml)
|
||||
|
||||
@@ -22,11 +22,11 @@ start
|
||||
|
||||
|Product|
|
||||
:ProductPriceQuoteEvent;
|
||||
if (type) is (<color:red>UNAVALIABLE) then
|
||||
if (type) is (<color:red>UNAVAILABLE) then
|
||||
|Order|
|
||||
:<color:red>OrderRejectedEvent;
|
||||
kill
|
||||
else (<color:green>AVALIABLE)
|
||||
else (<color:green>AVAILABLE)
|
||||
endif
|
||||
|
||||
|Order|
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<rect x="277" y="132.67" width="173" height="33.969" rx="3.5" ry="3.5" fill="#F1F1F1" stroke="#181818" stroke-width=".5"/>
|
||||
<text x="287" y="153.8057" fill="#000000" font-family="sans-serif" font-size="12" textLength="153">ProductPriceQuoteEvent</text>
|
||||
<polygon points="351.5 186.64 375.5 186.64 387.5 198.64 375.5 210.64 351.5 210.64 339.5 198.64" fill="#F1F1F1" stroke="#181818" stroke-width=".5"/>
|
||||
<text x="367.5" y="220.8462" fill="#FF0000" font-family="sans-serif" font-size="11" textLength="74">UNAVALIABLE</text>
|
||||
<text x="367.5" y="220.8462" fill="#FF0000" font-family="sans-serif" font-size="11" textLength="74">UNAVAILABLE</text>
|
||||
<text x="351.5" y="202.4438" fill="#000000" font-family="sans-serif" font-size="11" textLength="24">type</text>
|
||||
<text x="387.5" y="196.0415" fill="#008000" font-family="sans-serif" font-size="11" textLength="58">AVALIABLE</text>
|
||||
<text x="387.5" y="196.0415" fill="#008000" font-family="sans-serif" font-size="11" textLength="58">AVAILABLE</text>
|
||||
<line x1="271" x2="271" y1="12.745" y2="1264.8" stroke="#000" stroke-width="1.5"/>
|
||||
<rect x="574.5" y="364.98" width="164" height="33.969" rx="3.5" ry="3.5" fill="#F1F1F1" stroke="#181818" stroke-width=".5"/>
|
||||
<text x="584.5" y="386.1143" fill="#000000" font-family="sans-serif" font-size="12" textLength="144">StockReservationEvent</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@@ -39,21 +39,21 @@ type ProductPriceQuoteEvent_Type int32
|
||||
|
||||
const (
|
||||
ProductPriceQuoteEvent_TYPE_UNSPECIFIED ProductPriceQuoteEvent_Type = 0
|
||||
ProductPriceQuoteEvent_TYPE_UNAVALIABLE ProductPriceQuoteEvent_Type = 1
|
||||
ProductPriceQuoteEvent_TYPE_AVALIABLE ProductPriceQuoteEvent_Type = 2
|
||||
ProductPriceQuoteEvent_TYPE_UNAVAILABLE ProductPriceQuoteEvent_Type = 1
|
||||
ProductPriceQuoteEvent_TYPE_AVAILABLE ProductPriceQuoteEvent_Type = 2
|
||||
)
|
||||
|
||||
// Enum value maps for ProductPriceQuoteEvent_Type.
|
||||
var (
|
||||
ProductPriceQuoteEvent_Type_name = map[int32]string{
|
||||
0: "TYPE_UNSPECIFIED",
|
||||
1: "TYPE_UNAVALIABLE",
|
||||
2: "TYPE_AVALIABLE",
|
||||
1: "TYPE_UNAVAILABLE",
|
||||
2: "TYPE_AVAILABLE",
|
||||
}
|
||||
ProductPriceQuoteEvent_Type_value = map[string]int32{
|
||||
"TYPE_UNSPECIFIED": 0,
|
||||
"TYPE_UNAVALIABLE": 1,
|
||||
"TYPE_AVALIABLE": 2,
|
||||
"TYPE_UNAVAILABLE": 1,
|
||||
"TYPE_AVAILABLE": 2,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -434,8 +434,8 @@ var file_stocklet_events_v1_product_proto_rawDesc = []byte{
|
||||
0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x46, 0x0a, 0x04,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53,
|
||||
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59,
|
||||
0x50, 0x45, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x4c, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x01,
|
||||
0x12, 0x12, 0x0a, 0x0e, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x56, 0x41, 0x4c, 0x49, 0x41, 0x42,
|
||||
0x50, 0x45, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x01,
|
||||
0x12, 0x12, 0x0a, 0x0e, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42,
|
||||
0x4c, 0x45, 0x10, 0x02, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x68, 0x65, 0x78, 0x6f, 0x6c, 0x61, 0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x63, 0x6b,
|
||||
0x6c, 0x65, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67,
|
||||
|
||||
@@ -154,7 +154,7 @@ func (svc OrderService) PlaceOrder(ctx context.Context, req *pb.PlaceOrderReques
|
||||
}
|
||||
|
||||
func (svc OrderService) ProcessProductPriceQuoteEvent(ctx context.Context, req *eventpb.ProductPriceQuoteEvent) (*emptypb.Empty, error) {
|
||||
if req.Type == eventpb.ProductPriceQuoteEvent_TYPE_AVALIABLE {
|
||||
if req.Type == eventpb.ProductPriceQuoteEvent_TYPE_AVAILABLE {
|
||||
// Set order status to processing (from pending)
|
||||
// Dispatch OrderProcessingEvent
|
||||
_, err := svc.store.ProcessOrder(ctx, req.OrderId, req.TotalPrice)
|
||||
@@ -162,7 +162,7 @@ func (svc OrderService) ProcessProductPriceQuoteEvent(ctx context.Context, req *
|
||||
return nil, errors.WrapServiceError(errors.ErrCodeExtService, "failed to update in response to event", err)
|
||||
}
|
||||
|
||||
} else if req.Type == eventpb.ProductPriceQuoteEvent_TYPE_UNAVALIABLE {
|
||||
} else if req.Type == eventpb.ProductPriceQuoteEvent_TYPE_UNAVAILABLE {
|
||||
// Set order status to rejected (from pending)
|
||||
// Dispatch OrderRejectedEvent
|
||||
_, err := svc.store.RejectOrder(ctx, req.OrderId)
|
||||
|
||||
@@ -17,6 +17,7 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
@@ -212,7 +213,7 @@ func (c postgresController) PriceOrderProducts(ctx context.Context, orderId stri
|
||||
productPrice, ok := productPrices[productId]
|
||||
if !ok {
|
||||
// Prepare and dispatch failure product pricing event
|
||||
evt, evtTopic, err := product.PrepareProductPriceQuoteEvent_Unavaliable(orderId)
|
||||
evt, evtTopic, err := product.PrepareProductPriceQuoteEvent_Unavailable(orderId)
|
||||
if err != nil {
|
||||
return errors.WrapServiceError(errors.ErrCodeService, "failed to create event", err)
|
||||
}
|
||||
@@ -229,8 +230,8 @@ func (c postgresController) PriceOrderProducts(ctx context.Context, orderId stri
|
||||
totalPrice += productPrice * float32(quantity)
|
||||
}
|
||||
|
||||
// Prepare and dispatch succesful product pricing event
|
||||
evt, evtTopic, err := product.PrepareProductPriceQuoteEvent_Avaliable(
|
||||
// Prepare and dispatch successful product pricing event
|
||||
evt, evtTopic, err := product.PrepareProductPriceQuoteEvent_Available(
|
||||
orderId,
|
||||
productQuantities,
|
||||
productPrices,
|
||||
|
||||
@@ -58,12 +58,12 @@ func PrepareProductDeletedEvent(product *pb.Product) ([]byte, string, error) {
|
||||
return messaging.MarshalEvent(event, topic)
|
||||
}
|
||||
|
||||
func PrepareProductPriceQuoteEvent_Avaliable(orderId string, productQuantities map[string]int32, productPrices map[string]float32, totalPrice float32) ([]byte, string, error) {
|
||||
func PrepareProductPriceQuoteEvent_Available(orderId string, productQuantities map[string]int32, productPrices map[string]float32, totalPrice float32) ([]byte, string, error) {
|
||||
topic := messaging.Product_PriceQuotation_Topic
|
||||
event := &eventspb.ProductPriceQuoteEvent{
|
||||
Revision: 1,
|
||||
|
||||
Type: eventspb.ProductPriceQuoteEvent_TYPE_AVALIABLE,
|
||||
Type: eventspb.ProductPriceQuoteEvent_TYPE_AVAILABLE,
|
||||
OrderId: orderId,
|
||||
ProductQuantities: productQuantities,
|
||||
ProductPrices: productPrices,
|
||||
@@ -73,12 +73,12 @@ func PrepareProductPriceQuoteEvent_Avaliable(orderId string, productQuantities m
|
||||
return messaging.MarshalEvent(event, topic)
|
||||
}
|
||||
|
||||
func PrepareProductPriceQuoteEvent_Unavaliable(orderId string) ([]byte, string, error) {
|
||||
func PrepareProductPriceQuoteEvent_Unavailable(orderId string) ([]byte, string, error) {
|
||||
topic := messaging.Product_PriceQuotation_Topic
|
||||
event := &eventspb.ProductPriceQuoteEvent{
|
||||
Revision: 1,
|
||||
|
||||
Type: eventspb.ProductPriceQuoteEvent_TYPE_UNAVALIABLE,
|
||||
Type: eventspb.ProductPriceQuoteEvent_TYPE_UNAVAILABLE,
|
||||
OrderId: orderId,
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ message ProductDeletedEvent {
|
||||
message ProductPriceQuoteEvent {
|
||||
enum Type {
|
||||
TYPE_UNSPECIFIED = 0;
|
||||
TYPE_UNAVALIABLE = 1;
|
||||
TYPE_AVALIABLE = 2;
|
||||
TYPE_UNAVAILABLE = 1;
|
||||
TYPE_AVAILABLE = 2;
|
||||
}
|
||||
|
||||
int32 revision = 1;
|
||||
|
||||
Reference in New Issue
Block a user