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

Method Write

internal/servers/bundle_server.go:35–73  ·  view source on GitHub ↗

Write handles the writing of bundles.

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

Source from the content-addressed store, hash-verified

33
34// Write handles the writing of bundles.
35func (r *BundleServer) Write(ctx context.Context, request *v1.BundleWriteRequest) (*v1.BundleWriteResponse, error) {
36 ctx, span := internal.Tracer.Start(ctx, "bundle.write")
37 defer span.End()
38
39 v := request.Validate()
40 if v != nil {
41 return nil, status.Error(GetStatus(v), v.Error()) // Return validation error
42 }
43
44 for _, bundle := range request.GetBundles() {
45 for _, operation := range bundle.GetOperations() {
46 err := validation.ValidateBundleOperation(operation)
47 if err != nil {
48 return nil, status.Error(GetStatus(err), err.Error()) // Return operation validation error
49 }
50 }
51 }
52
53 var bundles []storage.Bundle
54 for _, b := range request.GetBundles() {
55 bundles = append(bundles, storage.Bundle{
56 Name: b.GetName(),
57 DataBundle: b,
58 TenantID: request.GetTenantId(),
59 })
60 }
61
62 names, err := r.bw.Write(ctx, bundles)
63 if err != nil {
64 span.RecordError(err)
65 span.SetStatus(otelCodes.Error, err.Error())
66 slog.ErrorContext(ctx, err.Error())
67 return nil, status.Error(GetStatus(err), err.Error())
68 }
69
70 return &v1.BundleWriteResponse{
71 Names: names,
72 }, nil
73}
74
75// Read handles the reading of bundles.
76func (r *BundleServer) Read(ctx context.Context, request *v1.BundleReadRequest) (*v1.BundleReadResponse, error) {

Callers

nothing calls this directly

Implementers 1

UnimplementedBundleServerpkg/pb/base/v1/service_grpc.pb.go

Calls 10

ValidateBundleOperationFunction · 0.92
GetStatusFunction · 0.85
StartMethod · 0.80
GetBundlesMethod · 0.80
GetOperationsMethod · 0.80
GetNameMethod · 0.65
WriteMethod · 0.65
ValidateMethod · 0.45
ErrorMethod · 0.45
GetTenantIdMethod · 0.45

Tested by

no test coverage detected