delrpc

package
v0.0.0-...-8f4bd53 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package delrpc provides a idiomatic Go client for Deluge RPC hosts.

See: https://deluge.readthedocs.io/en/latest/reference/api.html

Index

Constants

View Source
const (
	// DefaultTimeout is the default client timeout.
	DefaultTimeout = 10 * time.Second

	// DefaultUserAgent is the default client user agent.
	DefaultUserAgent = "delrpc/0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client is a deluge rpc client.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient creates a new deluge rpc client.

func (*Client) Close

func (cl *Client) Close() error

Close closes the connection.

func (*Client) Do

func (cl *Client) Do(ctx context.Context, method string, arguments, v interface{}) error

Do executes the qbittorrent web method, json marshaling the passed arguments and unmarshaling the response to v (if provided).

type ClientOption

type ClientOption = func(*Client)

ClientOption is a deluge rpc client option.

func WithCredentialFallback

func WithCredentialFallback(user, pass string) ClientOption

WithCredentialFallback is a deluge rpc client option to set the credential fallback to send to the rpc host.

func WithHost

func WithHost(host string) ClientOption

WithHost is a deluge rpc client option to set the remote host. Remote URL will become 'http://<host>/transmission/rpc'.

func WithLogf

func WithLogf(reqf, resf func(string, ...interface{})) ClientOption

WithLogf is a deluge rpc client option to set logging handlers HTTP request and response bodies.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout is a deluge rpc client option to set the rpc host request tiemout.

func WithURL

func WithURL(urlstr string) ClientOption

WithURL is a deluge rpc client option to set the remote URL.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent is a deluge rpc client option to set the user agent sent to the rpc host.

type Error

type Error string

Error is a transrpc error.

const (
	// ErrMismatchedRequestAndResponseIDs is the mismatched request and response ids error.
	ErrMismatchedRequestAndResponseIDs Error = "mismatched request and response ids"
)

Error values.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

Jump to

Keyboard shortcuts

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