example

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthExample        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowExample          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupExample = fmt.Errorf("proto: unexpected end of group")
)

Functions

func NewXClientForExample

func NewXClientForExample(addr string) (client.XClient, error)

NewXClientForExample creates a XClient. You can configure this client with more options such as etcd registry, serialize type, select algorithm and fail mode.

func RegisterExampleHTTPServer

func RegisterExampleHTTPServer(g *gin.RouterGroup, srv ExampleHTTPServer)

func ServeForExample

func ServeForExample(addr string) error

ServeForExample starts a server only registers one service. You can register more services and only start one server. It blocks until the application exits.

Types

type ExampleAble

type ExampleAble interface {

	// Login is server rpc method as defined
	Login(ctx context.Context, args *LoginReq, reply *LoginRsp) (err error)

	// Sms is server rpc method as defined
	Sms(ctx context.Context, args *SmsReq, reply *SmsRsp) (err error)
}

================== interface skeleton ===================

type ExampleClient

type ExampleClient struct {
	// contains filtered or unexported fields
}

================== client stub =================== Example is a client wrapped XClient.

func NewExampleClient

func NewExampleClient(xclient client.XClient) *ExampleClient

NewExampleClient wraps a XClient as ExampleClient. You can pass a shared XClient object created by NewXClientForExample.

func (*ExampleClient) Login

func (c *ExampleClient) Login(ctx context.Context, args *LoginReq) (reply *LoginRsp, err error)

Login is client rpc method as defined

func (*ExampleClient) Sms

func (c *ExampleClient) Sms(ctx context.Context, args *SmsReq) (reply *SmsRsp, err error)

Sms is client rpc method as defined

type ExampleHTTPServer

type ExampleHTTPServer interface {
	// Login
	Login(context.Context, *LoginReq) (*LoginRsp, error)
	// Sms
	Sms(context.Context, *SmsReq) (*SmsRsp, error)
}

ExampleHTTPServer

type ExampleImpl

type ExampleImpl struct{}

================== server skeleton ===================

func (*ExampleImpl) Login

func (s *ExampleImpl) Login(ctx context.Context, args *LoginReq, reply *LoginRsp) (err error)

Login is server rpc method as defined

func (*ExampleImpl) Sms

func (s *ExampleImpl) Sms(ctx context.Context, args *SmsReq, reply *SmsRsp) (err error)

Sms is server rpc method as defined

type ExampleOneClient

type ExampleOneClient struct {
	// contains filtered or unexported fields
}

================== oneclient stub =================== ExampleOneClient is a client wrapped oneClient.

func NewExampleOneClient

func NewExampleOneClient(oneclient *client.OneClient) *ExampleOneClient

NewExampleOneClient wraps a OneClient as ExampleOneClient. You can pass a shared OneClient object created by NewOneClientForExample.

func (*ExampleOneClient) Login

func (c *ExampleOneClient) Login(ctx context.Context, args *LoginReq) (reply *LoginRsp, err error)

Login is client rpc method as defined

func (*ExampleOneClient) Sms

func (c *ExampleOneClient) Sms(ctx context.Context, args *SmsReq) (reply *SmsRsp, err error)

Sms is client rpc method as defined

type LoginReq

type LoginReq struct {
	// @gotags: binding:"required"
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	// @gotags: binding:"required"
	Password             string   `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*LoginReq) Descriptor

func (*LoginReq) Descriptor() ([]byte, []int)

func (*LoginReq) GetPassword

func (m *LoginReq) GetPassword() string

func (*LoginReq) GetUsername

func (m *LoginReq) GetUsername() string

func (*LoginReq) Marshal

func (m *LoginReq) Marshal() (dAtA []byte, err error)

func (*LoginReq) MarshalTo

func (m *LoginReq) MarshalTo(dAtA []byte) (int, error)

func (*LoginReq) MarshalToSizedBuffer

func (m *LoginReq) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LoginReq) ProtoMessage

func (*LoginReq) ProtoMessage()

func (*LoginReq) Reset

func (m *LoginReq) Reset()

func (*LoginReq) Size

func (m *LoginReq) Size() (n int)

func (*LoginReq) String

func (m *LoginReq) String() string

func (*LoginReq) Unmarshal

func (m *LoginReq) Unmarshal(dAtA []byte) error

func (*LoginReq) XXX_DiscardUnknown

func (m *LoginReq) XXX_DiscardUnknown()

func (*LoginReq) XXX_Marshal

func (m *LoginReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LoginReq) XXX_Merge

func (m *LoginReq) XXX_Merge(src proto.Message)

func (*LoginReq) XXX_Size

func (m *LoginReq) XXX_Size() int

func (*LoginReq) XXX_Unmarshal

func (m *LoginReq) XXX_Unmarshal(b []byte) error

type LoginRsp

type LoginRsp struct {
	Token                string   `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	ExpiresAt            int64    `protobuf:"varint,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*LoginRsp) Descriptor

func (*LoginRsp) Descriptor() ([]byte, []int)

func (*LoginRsp) GetExpiresAt

func (m *LoginRsp) GetExpiresAt() int64

func (*LoginRsp) GetToken

func (m *LoginRsp) GetToken() string

func (*LoginRsp) Marshal

func (m *LoginRsp) Marshal() (dAtA []byte, err error)

func (*LoginRsp) MarshalTo

func (m *LoginRsp) MarshalTo(dAtA []byte) (int, error)

func (*LoginRsp) MarshalToSizedBuffer

func (m *LoginRsp) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LoginRsp) ProtoMessage

func (*LoginRsp) ProtoMessage()

func (*LoginRsp) Reset

func (m *LoginRsp) Reset()

func (*LoginRsp) Size

func (m *LoginRsp) Size() (n int)

func (*LoginRsp) String

func (m *LoginRsp) String() string

func (*LoginRsp) Unmarshal

func (m *LoginRsp) Unmarshal(dAtA []byte) error

func (*LoginRsp) XXX_DiscardUnknown

func (m *LoginRsp) XXX_DiscardUnknown()

func (*LoginRsp) XXX_Marshal

func (m *LoginRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LoginRsp) XXX_Merge

func (m *LoginRsp) XXX_Merge(src proto.Message)

func (*LoginRsp) XXX_Size

func (m *LoginRsp) XXX_Size() int

func (*LoginRsp) XXX_Unmarshal

func (m *LoginRsp) XXX_Unmarshal(b []byte) error

type SmsReq

type SmsReq struct {
	// @gotags: binding:"required,mobile"
	Mobile               string   `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*SmsReq) Descriptor

func (*SmsReq) Descriptor() ([]byte, []int)

func (*SmsReq) GetMobile

func (m *SmsReq) GetMobile() string

func (*SmsReq) Marshal

func (m *SmsReq) Marshal() (dAtA []byte, err error)

func (*SmsReq) MarshalTo

func (m *SmsReq) MarshalTo(dAtA []byte) (int, error)

func (*SmsReq) MarshalToSizedBuffer

func (m *SmsReq) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SmsReq) ProtoMessage

func (*SmsReq) ProtoMessage()

func (*SmsReq) Reset

func (m *SmsReq) Reset()

func (*SmsReq) Size

func (m *SmsReq) Size() (n int)

func (*SmsReq) String

func (m *SmsReq) String() string

func (*SmsReq) Unmarshal

func (m *SmsReq) Unmarshal(dAtA []byte) error

func (*SmsReq) XXX_DiscardUnknown

func (m *SmsReq) XXX_DiscardUnknown()

func (*SmsReq) XXX_Marshal

func (m *SmsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SmsReq) XXX_Merge

func (m *SmsReq) XXX_Merge(src proto.Message)

func (*SmsReq) XXX_Size

func (m *SmsReq) XXX_Size() int

func (*SmsReq) XXX_Unmarshal

func (m *SmsReq) XXX_Unmarshal(b []byte) error

type SmsRsp

type SmsRsp struct {
	Code                 string   `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*SmsRsp) Descriptor

func (*SmsRsp) Descriptor() ([]byte, []int)

func (*SmsRsp) GetCode

func (m *SmsRsp) GetCode() string

func (*SmsRsp) Marshal

func (m *SmsRsp) Marshal() (dAtA []byte, err error)

func (*SmsRsp) MarshalTo

func (m *SmsRsp) MarshalTo(dAtA []byte) (int, error)

func (*SmsRsp) MarshalToSizedBuffer

func (m *SmsRsp) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SmsRsp) ProtoMessage

func (*SmsRsp) ProtoMessage()

func (*SmsRsp) Reset

func (m *SmsRsp) Reset()

func (*SmsRsp) Size

func (m *SmsRsp) Size() (n int)

func (*SmsRsp) String

func (m *SmsRsp) String() string

func (*SmsRsp) Unmarshal

func (m *SmsRsp) Unmarshal(dAtA []byte) error

func (*SmsRsp) XXX_DiscardUnknown

func (m *SmsRsp) XXX_DiscardUnknown()

func (*SmsRsp) XXX_Marshal

func (m *SmsRsp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SmsRsp) XXX_Merge

func (m *SmsRsp) XXX_Merge(src proto.Message)

func (*SmsRsp) XXX_Size

func (m *SmsRsp) XXX_Size() int

func (*SmsRsp) XXX_Unmarshal

func (m *SmsRsp) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL