MCPcopy
hub / github.com/kopia/kopia / handleInitialSessionHandshake

Method handleInitialSessionHandshake

internal/server/grpc_session.go:589–620  ·  view source on GitHub ↗
(srv grpcapi.KopiaRepository_SessionServer, dr repo.DirectRepository)

Source from the content-addressed store, hash-verified

587}
588
589func (s *Server) handleInitialSessionHandshake(srv grpcapi.KopiaRepository_SessionServer, dr repo.DirectRepository) (repo.WriteSessionOptions, error) {
590 initializeReq, err := srv.Recv()
591 if err != nil {
592 return repo.WriteSessionOptions{}, errors.Wrap(err, "unable to read initialization request")
593 }
594
595 ir := initializeReq.GetInitializeSession()
596 if ir == nil {
597 return repo.WriteSessionOptions{}, errors.New("missing initialization request")
598 }
599
600 scc := dr.ContentReader().SupportsContentCompression()
601
602 if err := s.send(srv, initializeReq.GetRequestId(), &grpcapi.SessionResponse{
603 Response: &grpcapi.SessionResponse_InitializeSession{
604 InitializeSession: &grpcapi.InitializeSessionResponse{
605 Parameters: &grpcapi.RepositoryParameters{
606 HashFunction: dr.ContentReader().ContentFormat().GetHashFunction(),
607 HmacSecret: dr.ContentReader().ContentFormat().GetHmacSecret(),
608 Splitter: dr.ObjectFormat().Splitter,
609 SupportsContentCompression: scc,
610 },
611 },
612 },
613 }); err != nil {
614 return repo.WriteSessionOptions{}, errors.Wrap(err, "unable to send response")
615 }
616
617 return repo.WriteSessionOptions{
618 Purpose: ir.GetPurpose(),
619 }, nil
620}
621
622// RegisterGRPCHandlers registers server gRPC handler.
623func (s *Server) RegisterGRPCHandlers(r grpc.ServiceRegistrar) {

Callers 1

SessionMethod · 0.95

Calls 10

sendMethod · 0.95
GetPurposeMethod · 0.80
ContentReaderMethod · 0.65
GetHashFunctionMethod · 0.65
ContentFormatMethod · 0.65
GetHmacSecretMethod · 0.65
ObjectFormatMethod · 0.65
GetInitializeSessionMethod · 0.45
GetRequestIdMethod · 0.45

Tested by

no test coverage detected