forked from pachyderm/pachyderm
/
server.go
55 lines (50 loc) · 1.57 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package server
import (
"sync"
"github.com/pachyderm/pachyderm/src/client/pkg/shard"
ppsclient "github.com/pachyderm/pachyderm/src/client/pps"
"github.com/pachyderm/pachyderm/src/server/pkg/metrics"
ppsserver "github.com/pachyderm/pachyderm/src/server/pps"
"go.pedge.io/proto/rpclog"
kube "k8s.io/kubernetes/pkg/client/unversioned"
)
// APIServer represents an api server.
type APIServer interface {
ppsclient.APIServer
ppsserver.InternalPodAPIServer
shard.Frontend
shard.Server
}
// NewAPIServer creates an APIServer.
func NewAPIServer(
hasher *ppsserver.Hasher,
address string,
kubeClient *kube.Client,
namespace string,
jobShimImage string,
jobImagePullPolicy string,
reporter *metrics.Reporter,
) APIServer {
return &apiServer{
Logger: protorpclog.NewLogger("pps.API"),
hasher: hasher,
address: address,
pfsAPIClient: nil,
pfsClientOnce: sync.Once{},
persistAPIClient: nil,
persistClientOnce: sync.Once{},
kubeClient: kubeClient,
shardCancelFuncs: make(map[uint64]func()),
shardCancelFuncsLock: sync.Mutex{},
pipelineCancelFuncs: make(map[string]func()),
pipelineCancelFuncsLock: sync.Mutex{},
jobCancelFuncs: make(map[string]func()),
jobCancelFuncsLock: sync.Mutex{},
version: shard.InvalidVersion,
versionLock: sync.RWMutex{},
namespace: namespace,
jobShimImage: jobShimImage,
jobImagePullPolicy: jobImagePullPolicy,
reporter: reporter,
}
}