File: example_ttrpc.pb.go

package info (click to toggle)
golang-gogottrpc 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 432 kB
  • sloc: makefile: 121; sh: 35
file content (57 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download | duplicates (2)
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
// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
// source: github.com/containerd/ttrpc/example/example.proto
package example

import (
	context "context"
	ttrpc "github.com/containerd/ttrpc"
	empty "github.com/golang/protobuf/ptypes/empty"
)

type ExampleService interface {
	Method1(ctx context.Context, req *Method1Request) (*Method1Response, error)
	Method2(ctx context.Context, req *Method1Request) (*empty.Empty, error)
}

func RegisterExampleService(srv *ttrpc.Server, svc ExampleService) {
	srv.Register("ttrpc.example.v1.Example", map[string]ttrpc.Method{
		"Method1": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
			var req Method1Request
			if err := unmarshal(&req); err != nil {
				return nil, err
			}
			return svc.Method1(ctx, &req)
		},
		"Method2": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
			var req Method1Request
			if err := unmarshal(&req); err != nil {
				return nil, err
			}
			return svc.Method2(ctx, &req)
		},
	})
}

type exampleClient struct {
	client *ttrpc.Client
}

func NewExampleClient(client *ttrpc.Client) ExampleService {
	return &exampleClient{
		client: client,
	}
}
func (c *exampleClient) Method1(ctx context.Context, req *Method1Request) (*Method1Response, error) {
	var resp Method1Response
	if err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method1", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}
func (c *exampleClient) Method2(ctx context.Context, req *Method1Request) (*empty.Empty, error) {
	var resp empty.Empty
	if err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method2", req, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}