apitest

package
v0.0.0-...-0001d10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

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 is an implementation of a client that sends requests to a bound server. The server is just the API implementation this is not supposed to be a client to make requests with real IO, but just to test a particular implementation

func NewClient

func NewClient(router *rpc.HttpRouter) *Client

NewClient creates a new client for calling the API

func (*Client) Request

func (c *Client) Request(req Request) (Response, error)

Request performs a request and returns the response generated by the server, or the error if any

func (*Client) RequestAPI

func (c *Client) RequestAPI(de rpc.Deserializer, req interface{}, session string, route Route) error

RequestAPI performs a request to the API

type EventClient

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

EventClient is the client implementation for the Event API

func NewEventClient

func NewEventClient(router *rpc.HttpRouter) *EventClient

NewEventClient creates a new instance of an event client with an underlying client and session ready to be used to execute a router API

func (*EventClient) PollEvent

PollEvent polls for subscription events

func (*EventClient) PollEventUntilNotEmpty

func (c *EventClient) PollEventUntilNotEmpty(
	ctx context.Context,
	req event.PollEventRequest,
) (event.PollEventResponse, error)

PollEventUntilNotEmpty polls for events until at least one event is received or it times out

func (*EventClient) Subscribe

Subscribe creates a subscription to an event topic

func (*EventClient) Unsubscribe

func (c *EventClient) Unsubscribe(
	ctx context.Context,
	req event.UnsubscribeRequest,
) error

Unsubscribe destroys an existing subscription to an event topic

type ID

type ID struct {
	ID uint64 `json:"id"`
}

type PollEventDataDeserialized

type PollEventDataDeserialized struct {
	Offset uint64            `json:"offset"`
	Events []event.DataEvent `json:"events"`
}

type PollEventDataDeserializer

type PollEventDataDeserializer struct {
	Events []event.Event
	Offset uint64
}

func (*PollEventDataDeserializer) Deserialize

func (d *PollEventDataDeserializer) Deserialize(r io.Reader) error

type PollServiceResponseDeserialized

type PollServiceResponseDeserialized struct {
	Offset uint64            `json:"offset"`
	Events []json.RawMessage `json:"events"`
}

type PollServiceResponseDeserializer

type PollServiceResponseDeserializer struct {
	Requests map[uint64]service.Request
	// contains filtered or unexported fields
}

func (*PollServiceResponseDeserializer) Deserialize

func (d *PollServiceResponseDeserializer) Deserialize(r io.Reader) error

type Request

type Request struct {
	// Route that uniquely identifies the handler that should
	// handle the request
	Route Route

	// Body of the request
	Body []byte

	// Headers defines metadata to specify different options on how
	// the request may be handled
	Headers map[string]string
}

Request identifies a request sent by a client and handled by a server

type Response

type Response struct {
	// Body is the content of the response
	Body []byte

	// Code may be used to identify whether the request
	// was handled successfully or not
	Code int
}

Response to a request

type Route

type Route struct {
	// Method that will be executed on the resource
	Method string

	// Path that indicates the resource or action to
	// be executed
	Path string
}

Route defines how a request will be multiplexed. A request endpoint should be uniquely identified by a route

type ServiceClient

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

ServiceClient is the client implementation for the Service API

func NewServiceClient

func NewServiceClient(router *rpc.HttpRouter) *ServiceClient

NewServiceClient creates a new instance of a service client with an underlying client and session ready to be used to execute a router API

func (*ServiceClient) DeployService

DeployService deploys the specific service

func (*ServiceClient) DeployServiceSync

func (c *ServiceClient) DeployServiceSync(
	ctx context.Context,
	req service.DeployServiceRequest,
) (service.Event, error)

DeployServiceSync makes a DeployService request and waits for the event response

func (*ServiceClient) ExecuteService

ExecuteService deploys the specific service

func (*ServiceClient) ExecuteServiceSync

func (c *ServiceClient) ExecuteServiceSync(
	ctx context.Context,
	req service.ExecuteServiceRequest,
) (service.Event, error)

ExecuteServiceSync makes a ExecuteService request and waits for the event response

func (*ServiceClient) GetCode

func (*ServiceClient) GetPublicKey

func (*ServiceClient) PollService

func (ServiceClient) PollServiceUntilNotEmpty

func (c ServiceClient) PollServiceUntilNotEmpty(
	ctx context.Context,
	req service.PollServiceRequest,
) (service.PollServiceResponse, error)

Jump to

Keyboard shortcuts

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