client

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound is returned when the object is not found or the iterator has reached the end.

Functions

func ReadActivities

func ReadActivities(it ActivityIterator, maxItems int) ([]*vocab.ActivityType, error)

ReadActivities reads the activities from the given iterator up to a maximum number specified by maxItems. If maxItems <= 0 then all activities are read.

func ReadReferences

func ReadReferences(it ReferenceIterator, maxItems int) ([]*url.URL, error)

ReadReferences reads the references from the given iterator up to a maximum number specified by maxItems. If maxItems <= 0 then all references are read.

Types

type ActivityIterator

type ActivityIterator interface {
	// Next returns the next activity or the ErrNotFound error if no more items are available.
	Next() (*vocab.ActivityType, error)
	// NextPage advances to the next page. If there are no more pages then an ErrNotFound error is returned.
	NextPage() (*url.URL, error)
	// SetNextIndex sets the index of the next activity within the current page that Next will return.
	SetNextIndex(int)
	// TotalItems returns the total number of items available at the moment the iterator was created.
	// This value remains constant throughout the lifetime of the iterator.
	TotalItems() int
	// CurrentPage returns the ID of the current page that the iterator is processing.
	CurrentPage() *url.URL
	// NextIndex returns the next index of the current page that will be processed. This function does not
	// advance the iterator.
	NextIndex() int
}

ActivityIterator iterates over the activities in a result set.

type Client

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

Client implements an ActivityPub client which retrieves ActivityPub objects (such as actors, activities, and collections) from remote sources.

func New

func New(cfg Config, t httpTransport, fetchPublicKey verifiable.PublicKeyFetcher, resolver serviceResolver) *Client

New returns a new ActivityPub client.

func (*Client) GetActivities

func (c *Client) GetActivities(iri *url.URL, order Order) (ActivityIterator, error)

GetActivities returns an iterator that reads activities at the given IRI. The IRI may reference a Collection, OrderedCollection, CollectionPage, or OrderedCollectionPage.

func (*Client) GetActor

func (c *Client) GetActor(actorIRI *url.URL) (*vocab.ActorType, error)

GetActor retrieves the actor at the given IRI.

func (*Client) GetPublicKey

func (c *Client) GetPublicKey(keyIRI *url.URL) (*vocab.PublicKeyType, error)

GetPublicKey retrieves the public key at the given IRI.

func (*Client) GetReferences

func (c *Client) GetReferences(iri *url.URL) (ReferenceIterator, error)

GetReferences returns an iterator that reads all references at the given IRI. The IRI either resolves to an ActivityPub actor, collection or ordered collection.

type Config

type Config struct {
	CacheSize       int
	CacheExpiration time.Duration
}

Config contains configuration parameters for the client.

type Order

type Order string

Order is the order in which activities are returned.

const (
	// Forward indicates that activities should be returned in the same order that they were retrieved
	// from the REST endpoint.
	Forward Order = "forward"
	// Reverse indicates that activities should be returned in reverse order that they were retrieved
	// from the REST endpoint..
	Reverse Order = "reverse"
)

type ReferenceIterator

type ReferenceIterator interface {
	Next() (*url.URL, error)
	TotalItems() int
}

ReferenceIterator iterates over the references in a result set.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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