-
Notifications
You must be signed in to change notification settings - Fork 110
/
manager.go
38 lines (32 loc) · 977 Bytes
/
manager.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
package session
import (
"context"
"github.com/google/uuid"
"google.golang.org/grpc"
"go.viam.com/rdk/resource"
)
// A Manager holds sessions for a particular robot and manages their lifetime.
type Manager interface {
Start(ctx context.Context, ownerID string) (*Session, error)
All() []*Session
FindByID(ctx context.Context, id uuid.UUID, ownerID string) (*Session, error)
AssociateResource(id uuid.UUID, resourceName resource.Name)
Close()
// ServerInterceptors returns gRPC interceptors to work with sessions.
ServerInterceptors() ServerInterceptors
}
// ServerInterceptors provide gRPC interceptors to work with sessions.
type ServerInterceptors struct {
UnaryServerInterceptor func(
ctx context.Context,
req interface{},
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (interface{}, error)
StreamServerInterceptor func(
srv interface{},
ss grpc.ServerStream,
info *grpc.StreamServerInfo,
handler grpc.StreamHandler,
) error
}