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)
| 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. |
| 100 | func 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. |
| 117 | func GetBytes(ctx context.Context, src RO, cid blobcache.CID, hardMax int) ([]byte, error) { |
no test coverage detected