MCPcopy Create free account
hub / github.com/Permify/permify / RunBundle

Method RunBundle

internal/servers/data_server.go:381–416  ·  view source on GitHub ↗

RunBundle executes a bundle and returns its snapshot token.

(ctx context.Context, request *v1.BundleRunRequest)

Source from the content-addressed store, hash-verified

379
380// RunBundle executes a bundle and returns its snapshot token.
381func (r *DataServer) RunBundle(ctx context.Context, request *v1.BundleRunRequest) (*v1.BundleRunResponse, error) {
382 ctx, span := internal.Tracer.Start(ctx, "bundle.run")
383 defer span.End()
384
385 v := request.Validate()
386 if v != nil {
387 return nil, status.Error(GetStatus(v), v.Error()) // Return validation error
388 }
389
390 bundle, err := r.br.Read(ctx, request.GetTenantId(), request.GetName())
391 if err != nil {
392 span.RecordError(err)
393 span.SetStatus(otelCodes.Error, err.Error())
394 slog.ErrorContext(ctx, err.Error())
395 return nil, status.Error(GetStatus(err), err.Error())
396 }
397
398 err = validation.ValidateBundleArguments(bundle.GetArguments(), request.GetArguments())
399 if err != nil {
400 return nil, status.Error(GetStatus(err), err.Error()) // Return bundle argument validation error
401 }
402
403 snap, err := r.dw.RunBundle(ctx, request.GetTenantId(), request.GetArguments(), bundle)
404 if err != nil {
405 span.RecordError(err)
406 span.SetStatus(otelCodes.Error, err.Error())
407 slog.ErrorContext(ctx, err.Error())
408 return nil, status.Error(GetStatus(err), err.Error())
409 }
410
411 r.runBundleHistogram.Record(ctx, 1)
412
413 return &v1.BundleRunResponse{
414 SnapToken: snap.String(),
415 }, nil
416}

Callers

nothing calls this directly

Implementers 1

UnimplementedDataServerpkg/pb/base/v1/service_grpc.pb.go

Calls 11

ValidateBundleArgumentsFunction · 0.92
GetStatusFunction · 0.85
StartMethod · 0.80
ReadMethod · 0.65
GetNameMethod · 0.65
RunBundleMethod · 0.65
StringMethod · 0.65
ValidateMethod · 0.45
ErrorMethod · 0.45
GetTenantIdMethod · 0.45
GetArgumentsMethod · 0.45

Tested by

no test coverage detected