httpsender

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0, MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultAnnouncePath = "/announce"

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config) error

Option is a function that sets a value in a config.

func WithClient

func WithClient(c *http.Client) Option

WithClient uses an existing http.Client with the Sender.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures the timeout to wait for a response.

type Sender

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

Sender sends announce messages over HTTP.

func New

func New(announceURLs []*url.URL, peerID peer.ID, options ...Option) (*Sender, error)

New creates a new Sender that sends announce messages over HTTP. Announce messages are sent to the specified URLs. The addresses in announce messages are modified to include the specified peerID, which is necessary to communicate the publisher ID over HTTP.

func (*Sender) Close

func (s *Sender) Close() error

Close closes idle HTTP connections.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, msg message.Message) error

Send sends the Message to the announce URLs.

func (*Sender) SendJson

func (s *Sender) SendJson(ctx context.Context, msg message.Message) error

Jump to

Keyboard shortcuts

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