-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.go
71 lines (57 loc) · 2.61 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2019-present Open Networking Foundation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package list
import (
"context"
listapi "github.com/atomix/atomix-api/go/atomix/primitive/list"
"github.com/atomix/atomix-go-framework/pkg/atomix/errors"
)
// NewProxyServer creates a new read-only list server
func NewProxyServer(s listapi.ListServiceServer) listapi.ListServiceServer {
return &ProxyServer{
server: s,
}
}
// ProxyServer is a read-only list primitive server
type ProxyServer struct {
server listapi.ListServiceServer
}
func (s *ProxyServer) Size(ctx context.Context, request *listapi.SizeRequest) (*listapi.SizeResponse, error) {
return s.server.Size(ctx, request)
}
func (s *ProxyServer) Append(ctx context.Context, request *listapi.AppendRequest) (*listapi.AppendResponse, error) {
return nil, errors.NewUnauthorized("Append operation is not permitted")
}
func (s *ProxyServer) Insert(ctx context.Context, request *listapi.InsertRequest) (*listapi.InsertResponse, error) {
return nil, errors.NewUnauthorized("Insert operation is not permitted")
}
func (s *ProxyServer) Get(ctx context.Context, request *listapi.GetRequest) (*listapi.GetResponse, error) {
return s.server.Get(ctx, request)
}
func (s *ProxyServer) Set(ctx context.Context, request *listapi.SetRequest) (*listapi.SetResponse, error) {
return nil, errors.NewUnauthorized("Set operation is not permitted")
}
func (s *ProxyServer) Remove(ctx context.Context, request *listapi.RemoveRequest) (*listapi.RemoveResponse, error) {
return nil, errors.NewUnauthorized("Remove operation is not permitted")
}
func (s *ProxyServer) Clear(ctx context.Context, request *listapi.ClearRequest) (*listapi.ClearResponse, error) {
return nil, errors.NewUnauthorized("Clear operation is not permitted")
}
func (s *ProxyServer) Events(request *listapi.EventsRequest, server listapi.ListService_EventsServer) error {
return s.server.Events(request, server)
}
func (s *ProxyServer) Elements(request *listapi.ElementsRequest, server listapi.ListService_ElementsServer) error {
return s.server.Elements(request, server)
}
var _ listapi.ListServiceServer = &ProxyServer{}