MCPcopy Create free account
hub / github.com/blobcache/blobcache / URLFor

Function URLFor

src/bcsdk/bcsdk.go:100–114  ·  view source on GitHub ↗

URLFor produces a URL for a Volume. If the Volume is a remote Volume than the OID of the Volume on the remote Node and the Endpoint of the remote Node will be included in the URL instead of the local Node.

(ctx context.Context, bc blobcache.Service, volh blobcache.Handle)

Source from the content-addressed store, hash-verified

98// If the Volume is a remote Volume than the OID of the Volume on the remote Node
99// and the Endpoint of the remote Node will be included in the URL instead of the local Node.
100func URLFor(ctx context.Context, bc blobcache.Service, volh blobcache.Handle) (*blobcache.URL, error) {
101 vinfo, err := bc.InspectVolume(ctx, volh)
102 if err != nil {
103 return nil, err
104 }
105 host, err := bc.Endpoint(ctx)
106 if err != nil {
107 return nil, err
108 }
109 fqoid := vinfo.FQOID(host.Node)
110 return &blobcache.URL{
111 Node: fqoid.Node,
112 OID: fqoid.OID,
113 }, nil
114}
115
116// GetBytes gets a blob, but gracefully handles ErrTooSmall by resizing the buffer and retrying.
117func GetBytes(ctx context.Context, src RO, cid blobcache.CID, hardMax int) ([]byte, error) {

Callers 1

git.goFile · 0.92

Calls 3

FQOIDMethod · 0.80
InspectVolumeMethod · 0.65
EndpointMethod · 0.65

Tested by

no test coverage detected