github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/proto/dispatch/v1/00_zerolog.go (about) 1 package dispatchv1 2 3 import ( 4 "github.com/rs/zerolog" 5 6 "github.com/authzed/spicedb/pkg/tuple" 7 ) 8 9 // MarshalZerologObject implements zerolog object marshalling. 10 func (cr *DispatchCheckRequest) MarshalZerologObject(e *zerolog.Event) { 11 e.Object("metadata", cr.Metadata) 12 e.Str("resource-type", tuple.StringRR(cr.ResourceRelation)) 13 e.Str("subject", tuple.StringONR(cr.Subject)) 14 e.Array("resource-ids", strArray(cr.ResourceIds)) 15 } 16 17 // MarshalZerologObject implements zerolog object marshalling. 18 func (cr *DispatchCheckResponse) MarshalZerologObject(e *zerolog.Event) { 19 e.Object("metadata", cr.Metadata) 20 21 results := zerolog.Dict() 22 for resourceID, result := range cr.ResultsByResourceId { 23 results.Str(resourceID, ResourceCheckResult_Membership_name[int32(result.Membership)]) 24 } 25 e.Dict("results", results) 26 } 27 28 // MarshalZerologObject implements zerolog object marshalling. 29 func (er *DispatchExpandRequest) MarshalZerologObject(e *zerolog.Event) { 30 e.Object("metadata", er.Metadata) 31 e.Str("expand", tuple.StringONR(er.ResourceAndRelation)) 32 e.Stringer("mode", er.ExpansionMode) 33 } 34 35 // MarshalZerologObject implements zerolog object marshalling. 36 func (cr *DispatchExpandResponse) MarshalZerologObject(e *zerolog.Event) { 37 e.Object("metadata", cr.Metadata) 38 } 39 40 // MarshalZerologObject implements zerolog object marshalling. 41 func (lr *DispatchLookupResourcesRequest) MarshalZerologObject(e *zerolog.Event) { 42 e.Object("metadata", lr.Metadata) 43 e.Str("object", tuple.StringRR(lr.ObjectRelation)) 44 e.Str("subject", tuple.StringONR(lr.Subject)) 45 e.Interface("context", lr.Context) 46 } 47 48 // MarshalZerologObject implements zerolog object marshalling. 49 func (lr *DispatchReachableResourcesRequest) MarshalZerologObject(e *zerolog.Event) { 50 e.Object("metadata", lr.Metadata) 51 e.Str("resource-type", tuple.StringRR(lr.ResourceRelation)) 52 e.Str("subject-type", tuple.StringRR(lr.SubjectRelation)) 53 e.Array("subject-ids", strArray(lr.SubjectIds)) 54 } 55 56 // MarshalZerologObject implements zerolog object marshalling. 57 func (ls *DispatchLookupSubjectsRequest) MarshalZerologObject(e *zerolog.Event) { 58 e.Object("metadata", ls.Metadata) 59 e.Str("resource-type", tuple.StringRR(ls.ResourceRelation)) 60 e.Str("subject-type", tuple.StringRR(ls.SubjectRelation)) 61 e.Array("resource-ids", strArray(ls.ResourceIds)) 62 } 63 64 type strArray []string 65 66 // MarshalZerologArray implements zerolog array marshalling. 67 func (strs strArray) MarshalZerologArray(a *zerolog.Array) { 68 for _, val := range strs { 69 a.Str(val) 70 } 71 } 72 73 // MarshalZerologObject implements zerolog object marshalling. 74 func (cr *DispatchLookupResourcesResponse) MarshalZerologObject(e *zerolog.Event) { 75 e.Object("metadata", cr.Metadata) 76 } 77 78 // MarshalZerologObject implements zerolog object marshalling. 79 func (cs *DispatchLookupSubjectsResponse) MarshalZerologObject(e *zerolog.Event) { 80 e.Object("metadata", cs.Metadata) 81 } 82 83 // MarshalZerologObject implements zerolog object marshalling. 84 func (x *ResolverMeta) MarshalZerologObject(e *zerolog.Event) { 85 e.Str("revision", x.AtRevision) 86 e.Uint32("depth", x.DepthRemaining) 87 } 88 89 // MarshalZerologObject implements zerolog object marshalling. 90 func (cr *ResponseMeta) MarshalZerologObject(e *zerolog.Event) { 91 e.Uint32("count", cr.DispatchCount) 92 }