rpc

package
v0.0.0-...-402a30c Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package rpc handles the rpc communication with the aria2 dameon

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertClosedNetworkConnectionError

func ConvertClosedNetworkConnectionError(err error) error

ConvertClosedNetworkConnectionError converts a TCP "closed network connection" error to a argo.ErrConnIsClosed

Types

type Adapter

type Adapter struct {
	Poster Poster
	Secret string
}

Adapter fulfills the argo.Caller interface, while allowing to choose a custom Poster and a secret tocken

func Adapt

func Adapt(c Poster, secret string) Adapter

Adapt a Poster and a secret to fulfill the argo.Caller interface

func (Adapter) Call

func (a Adapter) Call(method string, reply interface{}, options ...interface{}) error

Call the given RPC method and unmarshall the response in reply.

func (Adapter) CallWithID

func (a Adapter) CallWithID(method string, reply interface{}, id *string, options ...interface{}) error

CallWithID is similar to Call, but write the returned id as well.

func (Adapter) Close

func (a Adapter) Close() (err error)

Close gracefully closes the Poster

type Notification

type Notification struct {
	// JSON-RPC protocol.
	Version string `json:"jsonrpc"`

	// A String containing the name of the method to be invoked.
	Method string `json:"method"`

	// Object to pass as request parameter to the method.
	Params []struct {
		GID argo.GID `json:"gid"` // GID of the download
	} `json:"params"`
}

Notification from aria2

func (Notification) GID

func (r Notification) GID() []argo.GID

GID gathers the GID of the notification

func (Notification) Identifier

func (r Notification) Identifier() string

Identifier returns the rpc method

type Poster

type Poster interface {
	Post(Request) (Response, error)
	Close() error
}

Poster allows to perform Requests

type Request

type Request struct {
	// JSON-RPC protocol.
	Version string `json:"jsonrpc"`

	// A String containing the name of the method to be invoked.
	Method string `json:"method"`

	// Object to pass as request parameter to the method.
	Params interface{} `json:"params"`

	// The request id. This can be of any type. It is used to match the
	// response with the request that it is replying to.
	ID string `json:"id"`
}

Request represents a JSON-RPC request sent by a client.

type Response

type Response struct {
	Result json.RawMessage `json:"result"`
	ID     string          `json:"id"`
	Error  argo.ResponseError
}

Response represents a JSON-RPC response to a request

Directories

Path Synopsis
Package http implements http communication with the aria2 daemon
Package http implements http communication with the aria2 daemon
Package websocket implements websocket communication with the aria2 daemon
Package websocket implements websocket communication with the aria2 daemon

Jump to

Keyboard shortcuts

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