demo.pb.micro.go 2.56 KB
Newer Older
kzkzzzz's avatar
kzkzzzz committed
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: demo.proto

package demo

import (
	fmt "fmt"
	proto "google.golang.org/protobuf/proto"
	_ "google.golang.org/protobuf/types/known/timestamppb"
	math "math"
)

import (
	context "context"
	api "go-micro.dev/v4/api"
	client "go-micro.dev/v4/client"
	server "go-micro.dev/v4/server"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option

// Api Endpoints for Demo service

func NewDemoEndpoints() []*api.Endpoint {
	return []*api.Endpoint{}
}

// Client API for Demo service

type DemoService interface {
	GetDemo(ctx context.Context, in *DemoReq, opts ...client.CallOption) (*DemoResp, error)
	ListDemo(ctx context.Context, in *ListDemoReq, opts ...client.CallOption) (*ListDemoResp, error)
}

type demoService struct {
	c    client.Client
	name string
}

func NewDemoService(name string, c client.Client) DemoService {
	return &demoService{
		c:    c,
		name: name,
	}
}

func (c *demoService) GetDemo(ctx context.Context, in *DemoReq, opts ...client.CallOption) (*DemoResp, error) {
	req := c.c.NewRequest(c.name, "Demo.GetDemo", in)
	out := new(DemoResp)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *demoService) ListDemo(ctx context.Context, in *ListDemoReq, opts ...client.CallOption) (*ListDemoResp, error) {
	req := c.c.NewRequest(c.name, "Demo.ListDemo", in)
	out := new(ListDemoResp)
	err := c.c.Call(ctx, req, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// Server API for Demo service

type DemoHandler interface {
	GetDemo(context.Context, *DemoReq, *DemoResp) error
	ListDemo(context.Context, *ListDemoReq, *ListDemoResp) error
}

func RegisterDemoHandler(s server.Server, hdlr DemoHandler, opts ...server.HandlerOption) error {
	type demo interface {
		GetDemo(ctx context.Context, in *DemoReq, out *DemoResp) error
		ListDemo(ctx context.Context, in *ListDemoReq, out *ListDemoResp) error
	}
	type Demo struct {
		demo
	}
	h := &demoHandler{hdlr}
	return s.Handle(s.NewHandler(&Demo{h}, opts...))
}

type demoHandler struct {
	DemoHandler
}

func (h *demoHandler) GetDemo(ctx context.Context, in *DemoReq, out *DemoResp) error {
	return h.DemoHandler.GetDemo(ctx, in, out)
}

func (h *demoHandler) ListDemo(ctx context.Context, in *ListDemoReq, out *ListDemoResp) error {
	return h.DemoHandler.ListDemo(ctx, in, out)
}