diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go index 8fa4eac..7646cb7 100644 --- a/pkg/log/log_test.go +++ b/pkg/log/log_test.go @@ -69,7 +69,7 @@ func setupLogger(t *testing.T, l level) string { model.ContextKeyTxnID, model.ContextKeyMsgID, model.ContextKeySubscriberID, - model.ContextKeyModelID, + model.ContextKeyModuleID, }, } diff --git a/pkg/model/error_test.go b/pkg/model/error_test.go index 519b54a..1ac952e 100644 --- a/pkg/model/error_test.go +++ b/pkg/model/error_test.go @@ -204,9 +204,10 @@ func TestParseContextKey_ValidKeys(t *testing.T) { input string expected ContextKey }{ + {"transaction_id", ContextKeyTxnID}, {"message_id", ContextKeyMsgID}, {"subscriber_id", ContextKeySubscriberID}, - {"model_id", ContextKeyModelID}, + {"module_id", ContextKeyModuleID}, } for _, tt := range tests { diff --git a/pkg/model/model.go b/pkg/model/model.go index 7d39eb1..a91e2a3 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -51,21 +51,22 @@ const ( // ContextKeySubscriberID is the context key used to store and retrieve the subscriber ID in a request context. ContextKeySubscriberID ContextKey = "subscriber_id" - // ContextKeyModelID is the context key for storing and retrieving the model ID from a request context. - ContextKeyModelID ContextKey = "model_id" + // ContextKeyModuleID is the context key for storing and retrieving the model ID from a request context. + ContextKeyModuleID ContextKey = "module_id" ) var contextKeys = map[string]ContextKey{ - "message_id": ContextKeyMsgID, - "subscriber_id": ContextKeySubscriberID, - "model_id": ContextKeyModelID, + "transaction_id": ContextKeyTxnID, + "message_id": ContextKeyMsgID, + "subscriber_id": ContextKeySubscriberID, + "module_id": ContextKeyModuleID, } // ParseContextKey converts a string into a valid ContextKey. func ParseContextKey(v string) (ContextKey, error) { key, ok := contextKeys[v] if !ok { - return "", fmt.Errorf("invalid context key: %s", key) + return "", fmt.Errorf("invalid context key: %s", v) } return key, nil }