async

package
v0.0.0-...-2ef8737 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Async = "async"

Variables

This section is empty.

Functions

func GetRequestTimeout

func GetRequestTimeout(tag string) time.Duration

Types

type Call

type Call struct {
	Req   Request
	Res   Response
	Done  chan bool
	Error error
}

Call represents an active request

func NewCall

func NewCall(req Request) *Call

type Client

type Client struct {
	Client        gnet.Client
	ClientHandler options.RequestResponseHandler
	Pending       map[string]*Call
	// contains filtered or unexported fields
}

func GetAsyncClient

func GetAsyncClient(settings options.TcpSettings) (*Client, error)

func (*Client) Destroy

func (p *Client) Destroy() error

func (*Client) IsClosed

func (c *Client) IsClosed() bool

func (*Client) SendRequest

func (c *Client) SendRequest(ctx context.Context, id string, payload []byte) (map[string]string, []byte, error)

type Handler

type Handler struct {
	*gcore.NetEventHandler
	// contains filtered or unexported fields
}

func NewAsyncHandler

func NewAsyncHandler(clt *Client) *Handler

func (*Handler) IncomingMessageHandling

func (h *Handler) IncomingMessageHandling(data []byte)

func (*Handler) OnReadMsg

func (h *Handler) OnReadMsg(c gcore.Conn, data []byte) error

func (*Handler) OnWriteError

func (h *Handler) OnWriteError(c gcore.Conn, data []byte, err error)

type Request

type Request struct {
	ID string `json:"id"`
}

Request represents a request from client

type Response

type Response struct {
	Parsed  map[string]string `json:"parsed"`
	ID      string            `json:"id"`
	Message []byte            `json:"message"`
}

Response is the reply message from the server

Jump to

Keyboard shortcuts

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