MCPcopy Index your code
hub / github.com/Permify/permify / LookupEntityStream

Method LookupEntityStream

internal/invoke/invoke.go:272–308  ·  view source on GitHub ↗

LookupEntityStream is a method that implements the LookupEntityStream interface. It calls the Stream method of the LookupEntityEngine with the provided context, PermissionLookupEntityRequest, and Permission_LookupEntityStreamServer, and returns an error if any.

(ctx context.Context, request *base.PermissionLookupEntityRequest, server base.Permission_LookupEntityStreamServer)

Source from the content-addressed store, hash-verified

270// It calls the Stream method of the LookupEntityEngine with the provided context, PermissionLookupEntityRequest, and Permission_LookupEntityStreamServer,
271// and returns an error if any.
272func (invoker *DirectInvoker) LookupEntityStream(ctx context.Context, request *base.PermissionLookupEntityRequest, server base.Permission_LookupEntityStreamServer) (err error) {
273 ctx, span := internal.Tracer.Start(ctx, "lookup-entity-stream", trace.WithAttributes(
274 attribute.KeyValue{Key: "tenant_id", Value: attribute.StringValue(request.GetTenantId())},
275 attribute.KeyValue{Key: "entity_type", Value: attribute.StringValue(request.GetEntityType())},
276 attribute.KeyValue{Key: "permission", Value: attribute.StringValue(request.GetPermission())},
277 attribute.KeyValue{Key: "subject", Value: attribute.StringValue(tuple.SubjectToString(request.GetSubject()))},
278 ))
279 defer span.End()
280
281 // Set SnapToken if not provided
282 if request.GetMetadata().GetSnapToken() == "" { // Check if the request has a SnapToken.
283 var st token.SnapToken
284 st, err = invoker.dataReader.HeadSnapshot(ctx, request.GetTenantId()) // Retrieve the head snapshot from the relationship reader.
285 if err != nil {
286 span.RecordError(err)
287 span.SetStatus(otelCodes.Error, err.Error())
288 return err
289 }
290 request.Metadata.SnapToken = st.Encode().String() // Set the SnapToken in the request metadata.
291 }
292
293 // Set SchemaVersion if not provided
294 if request.GetMetadata().GetSchemaVersion() == "" { // Check if the request has a SchemaVersion.
295 request.Metadata.SchemaVersion, err = invoker.schemaReader.HeadVersion(ctx, request.GetTenantId()) // Retrieve the head schema version from the schema reader.
296 if err != nil {
297 span.RecordError(err)
298 span.SetStatus(otelCodes.Error, err.Error())
299 return err
300 }
301 }
302
303 resp := invoker.lo.LookupEntityStream(ctx, request, server)
304
305 invoker.lookupEntityHistogram.Record(ctx, 1)
306
307 return resp
308}
309
310// LookupSubject is a method of the DirectInvoker structure. It handles the task of looking up subjects
311// and returning the results in a response.

Callers

nothing calls this directly

Calls 15

EncodeMethod · 0.95
SubjectToStringFunction · 0.92
StartMethod · 0.80
GetEntityTypeMethod · 0.80
HeadSnapshotMethod · 0.65
StringMethod · 0.65
HeadVersionMethod · 0.65
LookupEntityStreamMethod · 0.65
GetTenantIdMethod · 0.45
GetPermissionMethod · 0.45
GetSubjectMethod · 0.45
GetSnapTokenMethod · 0.45

Tested by

no test coverage detected