resolver

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

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

Resolver represents a resolver that can resolve data in a CAS based on a CID (with possible hint) and a WebCAS URL.

func New

func New(casClient extendedcasclient.Client, ipfsReader ipfsReader, webCASResolver WebCASResolver,
	metrics metricsProvider) *Resolver

New returns a new Resolver. ipfsReader is optional. If not provided (is nil), CIDs with IPFS hints won't be resolvable.

func (*Resolver) Resolve

func (h *Resolver) Resolve(_ *url.URL, hashWithPossibleHint string, data []byte) ([]byte, string, error)

Resolve does the following:

1. If data is provided (not nil), then it will be stored via the local CAS. That data passed in will then simply be returned back to the caller, along with the hashlink of the stored data. 2. If data is not provided (is nil), then the local CAS will be checked to see if it has data at the cid provided. If it does, then it is returned. If it doesn't, and a webCASURL is provided, then the data will be retrieved by querying the webCASURL. This data will then get stored in the local CAS. Finally, the data is returned to the caller, along with the hashlink of the stored data. In both cases above, the CID produced by the local CAS will be checked against the cid passed in to ensure they are the same.

type WebCASResolver

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

WebCASResolver is used to resolve data from another Oak server's CAS.

func NewWebCASResolver

func NewWebCASResolver(httpClient httpClient, webFingerClient *webfingerclient.Client,
	webFingerURIScheme string) WebCASResolver

NewWebCASResolver returns a new WebCASResolver.

func (*WebCASResolver) GetDataViaWebCASEndpoint

func (w *WebCASResolver) GetDataViaWebCASEndpoint(webCASEndpoint *url.URL) ([]byte, error)

GetDataViaWebCASEndpoint retrieves data from the given webCASEndpoint and returns it.

func (*WebCASResolver) Resolve

func (w *WebCASResolver) Resolve(domain, cid string) ([]byte, error)

Resolve returns the data stored at cid via the WebCAS hosted at domain. First, a WebFinger is done at domain in order to determine the WebCAS URL. Then the data is retrieved using the WebCAS URL.

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