forked from authzed/spicedb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
47 lines (38 loc) · 997 Bytes
/
client.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
package e2e
import (
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"google.golang.org/grpc"
)
// Client holds versioned clients to spicedb that all share the same connection
type Client interface {
V1() v1Client
}
type v1Client interface {
Permissions() v1.PermissionsServiceClient
Schema() v1.SchemaServiceClient
}
type spiceDBClient struct {
v1Client v1Client
}
func (c *spiceDBClient) V1() v1Client {
return c.v1Client
}
type spiceDBv1Client struct {
v1.PermissionsServiceClient
v1.SchemaServiceClient
}
func (s *spiceDBv1Client) Permissions() v1.PermissionsServiceClient {
return s
}
func (s *spiceDBv1Client) Schema() v1.SchemaServiceClient {
return s
}
// NewClient returns a spicedb Client for the given grpc connection
func NewClient(conn *grpc.ClientConn) Client {
return &spiceDBClient{
v1Client: &spiceDBv1Client{
PermissionsServiceClient: v1.NewPermissionsServiceClient(conn),
SchemaServiceClient: v1.NewSchemaServiceClient(conn),
},
}
}