go-micro.dev/v5@v5.12.0/server/proto/server.pb.micro.go (about)

     1  // Code generated by protoc-gen-micro. DO NOT EDIT.
     2  // source: server.proto
     3  
     4  package go_micro_server
     5  
     6  import (
     7  	fmt "fmt"
     8  	proto "github.com/golang/protobuf/proto"
     9  	math "math"
    10  )
    11  
    12  import (
    13  	context "context"
    14  	client "go-micro.dev/v5/client"
    15  	server "go-micro.dev/v5/server"
    16  )
    17  
    18  // Reference imports to suppress errors if they are not otherwise used.
    19  var _ = proto.Marshal
    20  var _ = fmt.Errorf
    21  var _ = math.Inf
    22  
    23  // This is a compile-time assertion to ensure that this generated file
    24  // is compatible with the proto package it is being compiled against.
    25  // A compilation error at this line likely means your copy of the
    26  // proto package needs to be updated.
    27  const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
    28  
    29  // Reference imports to suppress errors if they are not otherwise used.
    30  var _ context.Context
    31  var _ client.Option
    32  var _ server.Option
    33  
    34  // Client API for Server service
    35  
    36  type ServerService interface {
    37  	Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error)
    38  	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error)
    39  }
    40  
    41  type serverService struct {
    42  	c    client.Client
    43  	name string
    44  }
    45  
    46  func NewServerService(name string, c client.Client) ServerService {
    47  	return &serverService{
    48  		c:    c,
    49  		name: name,
    50  	}
    51  }
    52  
    53  func (c *serverService) Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error) {
    54  	req := c.c.NewRequest(c.name, "Server.Handle", in)
    55  	out := new(HandleResponse)
    56  	err := c.c.Call(ctx, req, out, opts...)
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  	return out, nil
    61  }
    62  
    63  func (c *serverService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error) {
    64  	req := c.c.NewRequest(c.name, "Server.Subscribe", in)
    65  	out := new(SubscribeResponse)
    66  	err := c.c.Call(ctx, req, out, opts...)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	return out, nil
    71  }
    72  
    73  // Server API for Server service
    74  
    75  type ServerHandler interface {
    76  	Handle(context.Context, *HandleRequest, *HandleResponse) error
    77  	Subscribe(context.Context, *SubscribeRequest, *SubscribeResponse) error
    78  }
    79  
    80  func RegisterServerHandler(s server.Server, hdlr ServerHandler, opts ...server.HandlerOption) error {
    81  	type server interface {
    82  		Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error
    83  		Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error
    84  	}
    85  	type Server struct {
    86  		server
    87  	}
    88  	h := &serverHandler{hdlr}
    89  	return s.Handle(s.NewHandler(&Server{h}, opts...))
    90  }
    91  
    92  type serverHandler struct {
    93  	ServerHandler
    94  }
    95  
    96  func (h *serverHandler) Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error {
    97  	return h.ServerHandler.Handle(ctx, in, out)
    98  }
    99  
   100  func (h *serverHandler) Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error {
   101  	return h.ServerHandler.Subscribe(ctx, in, out)
   102  }