MCPcopy
hub / github.com/kopia/kopia / handleSessionRequest

Method handleSessionRequest

internal/server/grpc_session.go:167–214  ·  view source on GitHub ↗
(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, usernameAtHostname string, req *grpcapi.SessionRequest, respond func(*grpcapi.SessionResponse))

Source from the content-addressed store, hash-verified

165var tracer = otel.Tracer("kopia/grpc")
166
167func (s *Server) handleSessionRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, usernameAtHostname string, req *grpcapi.SessionRequest, respond func(*grpcapi.SessionResponse)) {
168 if req.GetTraceContext() != nil {
169 var tc propagation.TraceContext
170
171 ctx = tc.Extract(ctx, propagation.MapCarrier(req.GetTraceContext()))
172 }
173
174 switch inner := req.GetRequest().(type) {
175 case *grpcapi.SessionRequest_GetContentInfo:
176 respond(handleGetContentInfoRequest(ctx, dw, authz, inner.GetContentInfo))
177
178 case *grpcapi.SessionRequest_GetContent:
179 respond(handleGetContentRequest(ctx, dw, authz, inner.GetContent))
180
181 case *grpcapi.SessionRequest_WriteContent:
182 respond(handleWriteContentRequest(ctx, dw, authz, inner.WriteContent))
183
184 case *grpcapi.SessionRequest_Flush:
185 respond(handleFlushRequest(ctx, dw, authz, inner.Flush))
186
187 case *grpcapi.SessionRequest_GetManifest:
188 respond(handleGetManifestRequest(ctx, dw, authz, inner.GetManifest))
189
190 case *grpcapi.SessionRequest_PutManifest:
191 respond(handlePutManifestRequest(ctx, dw, authz, inner.PutManifest))
192
193 case *grpcapi.SessionRequest_FindManifests:
194 handleFindManifestsRequest(ctx, dw, authz, inner.FindManifests, respond)
195
196 case *grpcapi.SessionRequest_DeleteManifest:
197 respond(handleDeleteManifestRequest(ctx, dw, authz, inner.DeleteManifest))
198
199 case *grpcapi.SessionRequest_PrefetchContents:
200 respond(handlePrefetchContentsRequest(ctx, dw, authz, inner.PrefetchContents))
201
202 case *grpcapi.SessionRequest_ApplyRetentionPolicy:
203 respond(handleApplyRetentionPolicyRequest(ctx, dw, authz, usernameAtHostname, inner.ApplyRetentionPolicy))
204
205 case *grpcapi.SessionRequest_SendNotification:
206 respond(s.handleSendNotificationRequest(ctx, dw, authz, inner.SendNotification))
207
208 case *grpcapi.SessionRequest_InitializeSession:
209 respond(errorResponse(errors.New("InitializeSession must be the first request in a session")))
210
211 default:
212 respond(errorResponse(errors.New("unhandled session request")))
213 }
214}
215
216func handleGetContentInfoRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.GetContentInfoRequest) *grpcapi.SessionResponse {
217 ctx, span := tracer.Start(ctx, "GRPCSession.GetContentInfo")

Callers 1

SessionMethod · 0.95

Tested by

no test coverage detected