client

package module
v0.0.0-...-8bfd799 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client enables generic calls to micro

func NewClient

func NewClient(options *Options) *Client

NewClient returns a generic micro client that connects to live by default

func (*Client) Call

func (client *Client) Call(service, endpoint string, request, response interface{}) error

Call enables you to access any endpoint of any service on Micro

func (*Client) SetToken

func (client *Client) SetToken(t string)

SetToken sets the api auth token

func (*Client) Stream

func (client *Client) Stream(service, endpoint string, request interface{}) (*Stream, error)

Stream enables the ability to stream via websockets

type Options

type Options struct {
	// Token for authentication
	Token string
	// Address of the micro platform.
	// By default it connects to live. Change it or use the local flag
	// to connect to your local installation.
	Address string
	// Helper flag to help users connect to the default local address
	Local bool
}

Options of the Client

type Request

type Request struct {
	// eg. "go.micro.srv.greeter"
	Service string `json:"service"`
	// eg. "Say.Hello"
	Endpoint string `json:"endpoint"`
	// json and then base64 encoded body
	Body string `json:"body"`
}

Request is the request of the generic `api-client` call

type Response

type Response struct {
	// json and base64 encoded response body
	Body string `json:"body"`
	// error fields. Error json example
	// {"id":"go.micro.client","code":500,"detail":"malformed method name: \"\"","status":"Internal Server Error"}
	Code   int    `json:"code"`
	ID     string `json:"id"`
	Detail string `json:"detail"`
	Status string `json:"status"`
}

Response is the response of the generic `api-client` call.

type Stream

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

func (*Stream) Recv

func (s *Stream) Recv(v interface{}) error

func (*Stream) Send

func (s *Stream) Send(v interface{}) error

Jump to

Keyboard shortcuts

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