MCPcopy
hub / github.com/kopia/kopia / New

Function New

internal/server/server.go:1109–1141  ·  view source on GitHub ↗

New creates a Server. The server will manage sources for a given username@hostname.

(ctx context.Context, options *Options)

Source from the content-addressed store, hash-verified

1107// New creates a Server.
1108// The server will manage sources for a given username@hostname.
1109func New(ctx context.Context, options *Options) (*Server, error) {
1110 if options.Authorizer == nil {
1111 return nil, errors.New("missing authorizer")
1112 }
1113
1114 if options.PasswordPersist == nil {
1115 return nil, errors.New("missing password persistence")
1116 }
1117
1118 if options.AuthCookieSigningKey == "" {
1119 // generate random signing key
1120 options.AuthCookieSigningKey = uuid.New().String()
1121 }
1122
1123 s := &Server{
1124 rootctx: ctx,
1125 options: *options,
1126 sourceManagers: map[snapshot.SourceInfo]*sourceManager{},
1127 maxParallelSnapshots: 1,
1128 grpcServerState: makeGRPCServerState(options.MaxConcurrency),
1129 authenticator: options.Authenticator,
1130 authorizer: options.Authorizer,
1131 taskmgr: uitask.NewManager(options.PersistentLogs),
1132 mounts: map[object.ID]mount.Controller{},
1133 authCookieSigningKey: []byte(options.AuthCookieSigningKey),
1134 nextRefreshTime: clock.Now().Add(options.RefreshInterval),
1135 schedulerRefresh: make(chan string, 1),
1136 }
1137
1138 s.parallelSnapshotsChanged = sync.NewCond(&s.parallelSnapshotsMutex)
1139
1140 return s, nil
1141}

Callers 2

runMethod · 0.92
StartServerContextFunction · 0.92

Calls 5

NewManagerFunction · 0.92
NowFunction · 0.92
makeGRPCServerStateFunction · 0.85
StringMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected