rpc

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	HTTPClient aur.HTTPRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []aur.RequestEditorFn
	// contains filtered or unexported fields
}

Client for AUR searching and querying.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, query *aur.Query) ([]aur.Pkg, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context, pkgs []string) ([]aur.Pkg, error)

Info shows Info for one or multiple packages.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, by aur.By) ([]aur.Pkg, error)

Search queries the AUR DB with an optional By field. Use By.None for default query param (name-desc).

type ClientInterface

type ClientInterface interface {
	aur.QueryClient
	// Search queries the AUR DB with an optional By filter.
	// Use By.None for default query param (name-desc)
	Search(ctx context.Context, query string, by aur.By) ([]aur.Pkg, error)

	// Info gives detailed information on existing package.
	Info(ctx context.Context, pkgs []string) ([]aur.Pkg, error)
}

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL allows overriding the default base URL of the client.

func WithBatchSize

func WithBatchSize(batchSize int) ClientOption

WithBatchSize allows overriding the default value for batch size.

func WithHTTPClient

func WithHTTPClient(doer aur.HTTPRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithLogFn

func WithLogFn(fn LogFn) ClientOption

WithLogFn allows overriding the default log function.

func WithRequestEditorFn

func WithRequestEditorFn(fn aur.RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type LogFn

type LogFn func(a ...any)

Jump to

Keyboard shortcuts

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