Documentation ¶
Overview ¶
Package client implements a Camlistore client.
Index ¶
- Variables
- func AddFlags()
- func ExplicitServer() string
- func ListMissingDestinationBlobs(destMissing chan<- blob.SizedRef, sizeMismatch chan<- blob.Ref, ...)
- type ByCountAndBytes
- type Client
- func (c *Client) BlobRoot() (string, error)
- func (c *Client) Describe(req *search.DescribeRequest) (*search.DescribeResponse, error)
- func (c *Client) DialFunc() func(network, addr string) (net.Conn, error)
- func (c *Client) EnumerateBlobs(ctx *context.Context, dest chan<- blob.SizedRef, after string, limit int) error
- func (c *Client) EnumerateBlobsOpts(ctx *context.Context, ch chan<- blob.SizedRef, opts EnumerateOpts) error
- func (c *Client) FetchSchemaBlob(b blob.Ref) (*schema.Blob, error)
- func (c *Client) FetchStreaming(b blob.Ref) (io.ReadCloser, int64, error)
- func (c *Client) FetchVia(b blob.Ref, v []blob.Ref) (body io.ReadCloser, size int64, err error)
- func (c *Client) FileHasContents(f, wholeRef blob.Ref) bool
- func (c *Client) GetPermanodesWithAttr(req *search.WithAttrRequest) (*search.WithAttrResponse, error)
- func (c *Client) GetRecentPermanodes(req *search.RecentRequest) (*search.RecentResponse, error)
- func (c *Client) IsIgnoredFile(fullpath string) bool
- func (c *Client) ReceiveBlob(br blob.Ref, source io.Reader) (blob.SizedRef, error)
- func (c *Client) RemoveBlob(b blob.Ref) error
- func (c *Client) RemoveBlobs(blobs []blob.Ref) error
- func (c *Client) Search(req *search.SearchQuery) (*search.SearchResult, error)
- func (c *Client) SearchExistingFileSchema(wholeRef blob.Ref) (blob.Ref, error)
- func (c *Client) SearchRoot() (string, error)
- func (c *Client) SecretRingFile() string
- func (c *Client) SetHTTPClient(client *http.Client)
- func (c *Client) SetHaveCache(cache HaveCache)
- func (c *Client) SetLogger(logger *log.Logger)
- func (c *Client) SetupAuth() error
- func (c *Client) SetupAuthFromString(a string) error
- func (c *Client) Signer() (*schema.Signer, error)
- func (c *Client) SignerPublicKeyBlobref() blob.Ref
- func (c *Client) SimpleEnumerateBlobs(ctx *context.Context, ch chan<- blob.SizedRef) error
- func (c *Client) StatBlobs(dest chan<- blob.SizedRef, blobs []blob.Ref) error
- func (c *Client) Stats() Stats
- func (c *Client) StorageGeneration() (string, error)
- func (c *Client) SyncHandlers() ([]*SyncInfo, error)
- func (c *Client) TLSConfig() (*tls.Config, error)
- func (c *Client) TransportForConfig(tc *TransportConfig) http.RoundTripper
- func (c *Client) Upload(h *UploadHandle) (*PutResult, error)
- func (c *Client) UploadAndSignBlob(b schema.AnyBlob) (*PutResult, error)
- func (c *Client) UploadBlob(b schema.AnyBlob) (*PutResult, error)
- func (c *Client) UploadNewPermanode() (*PutResult, error)
- func (c *Client) UploadPlannedPermanode(key string, sigTime time.Time) (*PutResult, error)
- type ClientOption
- type EnumerateOpts
- type HaveCache
- type PutResult
- type ResponseFormatError
- type Stats
- type SyncInfo
- type TransportConfig
- type UploadHandle
Constants ¶
This section is empty.
Variables ¶
var ErrNoSearchRoot = errors.New("client: server doesn't support search")
ErrNoSearchRoot is returned by SearchRoot if the server doesn't support search.
var ErrNoStorageGeneration = errors.New("client: server doesn't report a storage generation")
ErrNoStorageGeneration is returned by StorageGeneration if the server doesn't report a storage generation value.
var ErrNoSync = errors.New("client: server has no sync handlers")
ErrNoSync is returned by SyncHandlers if the server does not advertise syncs.
Functions ¶
func ExplicitServer ¶
func ExplicitServer() string
ExplicitServer returns the blobserver given in the flags, if any.
func ListMissingDestinationBlobs ¶
func ListMissingDestinationBlobs(destMissing chan<- blob.SizedRef, sizeMismatch chan<- blob.Ref, srcch, dstch <-chan blob.SizedRef)
ListMissingDestinationBlobs reads from 'srcch' and 'dstch' (sorted enumerations of blobs from two blob servers) and sends to 'destMissing' any blobs which appear on the source but not at the destination. destMissing is closed at the end. sizeMismatch is never closed.
Types ¶
type ByCountAndBytes ¶
func (*ByCountAndBytes) String ¶
func (bb *ByCountAndBytes) String() string
type Client ¶
type Client struct { // if set, we also skip the check against trustedCerts InsecureTLS bool // contains filtered or unexported fields }
A Client provides access to a Camlistore server.
func New ¶
New returns a new Camlistore Client. The provided server is either "host:port" (assumed http, not https) or a URL prefix, with or without a path, or a server alias from the client configuration file. A server alias should not be confused with a hostname, therefore it cannot contain any colon or period. Errors are not returned until subsequent operations.
func NewFromShareRoot ¶
func NewFromShareRoot(shareBlobURL string, opts ...ClientOption) (c *Client, target blob.Ref, err error)
NewFromShareRoot uses shareBlobURL to set up and return a client that will be used to fetch shared blobs.
func (*Client) BlobRoot ¶
BlobRoot returns the server's blobroot URL prefix. If the client was constructed with an explicit path, that path is used. Otherwise the server's default advertised blobRoot is used.
func (*Client) Describe ¶
func (c *Client) Describe(req *search.DescribeRequest) (*search.DescribeResponse, error)
func (*Client) DialFunc ¶
DialFunc returns the adequate dial function, depending on whether SSL is required, the client's config has some trusted certs, and we're on android. If the client's config has some trusted certs, the server's certificate will be checked against those in the config after the TLS handshake.
func (*Client) EnumerateBlobs ¶
func (*Client) EnumerateBlobsOpts ¶
func (c *Client) EnumerateBlobsOpts(ctx *context.Context, ch chan<- blob.SizedRef, opts EnumerateOpts) error
Note: closes ch.
func (*Client) FetchStreaming ¶
func (*Client) FileHasContents ¶
FileHasContents returns true iff f refers to a "file" or "bytes" schema blob, the server is configured with a "download helper", and the server responds that all chunks of 'f' are available and match the digest of wholeRef.
func (*Client) GetPermanodesWithAttr ¶
func (c *Client) GetPermanodesWithAttr(req *search.WithAttrRequest) (*search.WithAttrResponse, error)
func (*Client) GetRecentPermanodes ¶
func (c *Client) GetRecentPermanodes(req *search.RecentRequest) (*search.RecentResponse, error)
GetRecentPermanodes implements search.IGetRecentPermanodes against a remote server over HTTP.
func (*Client) IsIgnoredFile ¶
IsIgnoredFile returns whether the file at fullpath should be ignored by camput. The fullpath is checked against the ignoredFiles list, trying the following rules in this order: 1) star-suffix style matching (.e.g *.jpg). 2) Shell pattern match as done by http://golang.org/pkg/path/filepath/#Match 3) If the pattern is an absolute path to a directory, fullpath matches if it is that directory or a child of it. 4) If the pattern is a relative path, fullpath matches if it has pattern as a path component (i.e the pattern is a part of fullpath that fits exactly between two path separators).
func (*Client) ReceiveBlob ¶
func (*Client) RemoveBlob ¶
Remove the single blob. An error is returned if the server failed to remove the blob. Removing a non-existent blob isn't an error.
func (*Client) RemoveBlobs ¶
Remove the list of blobs. An error is returned if the server failed to remove a blob. Removing a non-existent blob isn't an error.
func (*Client) Search ¶
func (c *Client) Search(req *search.SearchQuery) (*search.SearchResult, error)
func (*Client) SearchExistingFileSchema ¶
SearchExistingFileSchema does a search query looking for an existing file with entire contents of wholeRef, then does a HEAD request to verify the file still exists on the server. If so, it returns that file schema's blobref.
May return (zero, nil) on ENOENT. A non-nil error is only returned if there were problems searching.
func (*Client) SearchRoot ¶
SearchRoot returns the server's search handler. If the server isn't running an index and search handler, the error will be ErrNoSearchRoot.
func (*Client) SecretRingFile ¶
SecretRingFile returns the filename to the user's GPG secret ring. The value comes from either a command-line flag, the CAMLI_SECRET_RING environment variable, the client config file's "identitySecretRing" value, or the operating system default location.
func (*Client) SetHTTPClient ¶
SetHTTPClient sets the Camlistore client's HTTP client. If nil, the default HTTP client is used.
func (*Client) SetHaveCache ¶
func (*Client) SetupAuth ¶
SetupAuth sets the client's authMode. It tries from the environment first if we're on android or in dev mode, and then from the client configuration.
func (*Client) SetupAuthFromString ¶
SetupAuthFromString configures the clients authentication mode from an explicit auth string.
func (*Client) SignerPublicKeyBlobref ¶
SignerPublicKeyBlobref returns the blobref of signer's public key. The blobref may not be valid (zero blob.Ref) if e.g the configuration is invalid or incomplete.
func (*Client) SimpleEnumerateBlobs ¶
Note: closes ch.
func (*Client) StorageGeneration ¶
StorageGeneration returns the server's unique ID for its storage generation, reset whenever storage is reset, moved, or partially lost.
This is a value that can be used in client cache keys to add certainty that they're talking to the same instance as previously.
If the server doesn't return such a value, the error will be ErrNoStorageGeneration.
func (*Client) SyncHandlers ¶
SyncHandlers returns the server's sync handlers "from" and "to" prefix URLs. If the server isn't running any sync handler, the error will be ErrNoSync.
func (*Client) TLSConfig ¶
TLSConfig returns the correct tls.Config depending on whether SSL is required, the client's config has some trusted certs, and we're on android.
func (*Client) TransportForConfig ¶
func (c *Client) TransportForConfig(tc *TransportConfig) http.RoundTripper
TransportForConfig returns a transport for the client, setting the correct Proxy, Dial, and TLSClientConfig if needed. It does not mutate c. It is the caller's responsibility to then use that transport to set the client's httpClient with SetHTTPClient.
func (*Client) UploadAndSignBlob ¶
func (*Client) UploadNewPermanode ¶
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
func OptionInsecure ¶
func OptionInsecure(v bool) ClientOption
func OptionTrustedCert ¶
func OptionTrustedCert(cert string) ClientOption
type EnumerateOpts ¶
type HaveCache ¶
type HaveCache interface { StatBlobCache(br blob.Ref) (size int64, ok bool) NoteBlobExists(br blob.Ref, size int64) }
A HaveCache caches whether a remote blobserver has a blob.
type PutResult ¶
func (*PutResult) SizedBlobRef ¶
type ResponseFormatError ¶
type ResponseFormatError error
type Stats ¶
type Stats struct { // The number of uploads that were requested, but perhaps // not actually performed if the server already had the items. UploadRequests ByCountAndBytes // The uploads which were actually sent to the blobserver // due to the server not having the blobs Uploads ByCountAndBytes }
type SyncInfo ¶
type SyncInfo struct { From string To string ToIndex bool // whether this sync is from a blob storage to an index }
SyncInfo holds the data that were acquired with a discovery and that are relevant to a syncHandler.
type TransportConfig ¶
type TransportConfig struct { // Proxy optionally specifies the Proxy for the transport. Useful with // camput for debugging even localhost requests. Proxy func(*http.Request) (*url.URL, error) Verbose bool // Verbose enables verbose logging of HTTP requests. }
TransportConfig contains options for SetupTransport.
type UploadHandle ¶
type UploadHandle struct { BlobRef blob.Ref Size int64 // or -1 if size isn't known Contents io.Reader Vivify bool }
func NewUploadHandleFromString ¶
func NewUploadHandleFromString(data string) *UploadHandle