mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 22:13:44 +03:00
[hw-7] add metrics, tracing
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"route256/cart/internal/domain/entity"
|
||||
"route256/cart/internal/domain/model"
|
||||
"route256/cart/internal/infra/http/metrics"
|
||||
)
|
||||
|
||||
type storage = map[entity.UID]*entity.Cart
|
||||
@@ -34,6 +35,7 @@ func (r *InMemoryRepository) AddItem(_ context.Context, userID entity.UID, item
|
||||
}
|
||||
|
||||
r.storage[userID] = cart
|
||||
metrics.SetInMemoryObjects(len(r.storage))
|
||||
}
|
||||
|
||||
if _, ok := cart.ItemCount[item.Product.Sku]; !ok {
|
||||
@@ -112,6 +114,7 @@ func (r *InMemoryRepository) DeleteItemsByUserID(_ context.Context, userID entit
|
||||
_, ok := r.storage[userID]
|
||||
if ok {
|
||||
delete(r.storage, userID)
|
||||
metrics.SetInMemoryObjects(len(r.storage))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user