service backend
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful

This commit is contained in:
Stephan D
2025-11-07 18:35:26 +01:00
parent 20e8f9acc4
commit 62a6631b9a
537 changed files with 48453 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package mzap
import (
me "github.com/tech/sendico/pkg/messaging/envelope"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
type envelopeMarshaler struct {
me.Envelope
}
func (e envelopeMarshaler) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("message_id", e.GetMessageId().String())
enc.AddString("sender", e.GetSender())
enc.AddTime("time_stamp", e.GetTimeStamp())
enc.AddString("type", e.GetSignature().StringType())
enc.AddString("action", e.GetSignature().StringAction())
return nil
}
func Envelope(envelope me.Envelope) zap.Field {
return zap.Object("envelope", envelopeMarshaler{envelope})
}

View File

@@ -0,0 +1,15 @@
package mzap
import (
"github.com/tech/sendico/pkg/db/storable"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.uber.org/zap"
)
func ObjRef(name string, objRef primitive.ObjectID) zap.Field {
return zap.String(name, objRef.Hex())
}
func StorableRef(obj storable.Storable) zap.Field {
return ObjRef(obj.Collection()+"_ref", *obj.GetID())
}