client

package
v0.0.0-...-3b294e6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2013 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSearchRoot = errors.New("client: server doesn't support search")

ErrNoSearchRoot is returned by SearchRoot if the server doesn't support search.

View Source
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.

View Source
var ErrNoSync = errors.New("client: server has no sync handlers")

ErrNoSync is returned by SyncHandlers if the server does not advertise syncs.

Functions

func AddFlags

func AddFlags()

func AndroidOutput

func AndroidOutput() bool

func Androidf

func Androidf(format string, args ...interface{})

func ConfigFilePath

func ConfigFilePath() string

func ExplicitServer

func ExplicitServer() string

ExplicitServer returns the blobserver given in the flags, if any.

func ListMissingDestinationBlobs

func ListMissingDestinationBlobs(destMissing chan<- blobref.SizedBlobRef, sizeMismatch chan<- *blobref.BlobRef, srcch, dstch <-chan blobref.SizedBlobRef)

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.

func NoteFileUploaded

func NoteFileUploaded(fullPath string, uploaded bool)

func SignerPublicKeyBlobref

func SignerPublicKeyBlobref() *blobref.BlobRef

TODO: move to config package?

Types

type AndroidStatsTransport

type AndroidStatsTransport struct {
	Rt http.RoundTripper
}

func (AndroidStatsTransport) RoundTrip

func (t AndroidStatsTransport) RoundTrip(req *http.Request) (res *http.Response, err error)

type AndroidStatusReceiver

type AndroidStatusReceiver struct {
	Sr   blobserver.StatReceiver
	Path string
}

androidStatusReceiver is a blobserver.StatReceiver wrapper that reports the full filename path and size of uploaded blobs. The android app wrapping camput watches stdout for this, for progress bars.

func (AndroidStatusReceiver) ReceiveBlob

func (asr AndroidStatusReceiver) ReceiveBlob(blob *blobref.BlobRef, source io.Reader) (blobref.SizedBlobRef, error)

func (AndroidStatusReceiver) StatBlobs

func (asr AndroidStatusReceiver) StatBlobs(dest chan<- blobref.SizedBlobRef, blobs []*blobref.BlobRef, wait time.Duration) error

type ByCountAndBytes

type ByCountAndBytes struct {
	Blobs int
	Bytes int64
}

func (*ByCountAndBytes) String

func (bb *ByCountAndBytes) String() string

type Client

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

A Client provides access to a Camlistore server.

func New

func New(server string) *Client

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. Errors are not returned until subsequent operations.

func NewFromShareRoot

func NewFromShareRoot(shareBlobURL string) (c *Client, target *blobref.BlobRef, err error)

func NewOrFail

func NewOrFail() *Client

func (*Client) BlobRoot

func (c *Client) BlobRoot() (string, error)

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) DialFunc

func (c *Client) DialFunc() func(network, addr string) (net.Conn, error)

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 (c *Client) EnumerateBlobs(dest chan<- blobref.SizedBlobRef, after string, limit int, wait time.Duration) error

func (*Client) EnumerateBlobsOpts

func (c *Client) EnumerateBlobsOpts(ch chan<- blobref.SizedBlobRef, opts EnumerateOpts) error

Note: closes ch.

func (*Client) FetchSchemaBlob

func (c *Client) FetchSchemaBlob(b *blobref.BlobRef) (*schema.Blob, error)

func (*Client) FetchStreaming

func (c *Client) FetchStreaming(b *blobref.BlobRef) (io.ReadCloser, int64, error)

func (*Client) FetchVia

func (c *Client) FetchVia(b *blobref.BlobRef, v []*blobref.BlobRef) (io.ReadCloser, int64, error)

func (*Client) FileHasContents

func (c *Client) FileHasContents(f, wholeRef *blobref.BlobRef) bool

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) GetBlobFetcher

func (c *Client) GetBlobFetcher() blobref.SeekFetcher

func (*Client) GetRecentPermanodes

func (c *Client) GetRecentPermanodes(req *search.RecentRequest) (*search.RecentResponse, error)

SearchRecent implements search.IGetRecentPermanodes against a remote server over HTTP.

func (*Client) GetTrustedCerts

func (c *Client) GetTrustedCerts() []string

func (*Client) ReceiveBlob

func (c *Client) ReceiveBlob(blob *blobref.BlobRef, source io.Reader) (blobref.SizedBlobRef, error)

func (*Client) RemoveBlob

func (c *Client) RemoveBlob(b *blobref.BlobRef) error

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

func (c *Client) RemoveBlobs(blobs []*blobref.BlobRef) error

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) SearchExistingFileSchema

func (c *Client) SearchExistingFileSchema(wholeRef *blobref.BlobRef) (*blobref.BlobRef, error)

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 (nil, nil) on ENOENT. A non-nil error is only returned if there were problems searching.

func (*Client) SearchRoot

func (c *Client) SearchRoot() (string, error)

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

func (c *Client) SecretRingFile() string

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

SetHTTPClient sets the Camlistore client's HTTP client. If nil, the default HTTP client is used.

func (*Client) SetHaveCache

func (c *Client) SetHaveCache(cache HaveCache)

func (*Client) SetLogger

func (c *Client) SetLogger(logger *log.Logger)

func (*Client) SetupAuth

func (c *Client) SetupAuth() error

func (*Client) SetupAuthFromConfig

func (c *Client) SetupAuthFromConfig(conf jsonconfig.Obj) error

func (*Client) SignerPublicKeyBlobref

func (c *Client) SignerPublicKeyBlobref() *blobref.BlobRef

Returns blobref of signer's public key, or nil if unconfigured.

func (*Client) SimpleEnumerateBlobs

func (c *Client) SimpleEnumerateBlobs(ch chan<- blobref.SizedBlobRef) error

Note: closes ch.

func (*Client) StatBlobs

func (c *Client) StatBlobs(dest chan<- blobref.SizedBlobRef, blobs []*blobref.BlobRef, wait time.Duration) error

func (*Client) Stats

func (c *Client) Stats() Stats

func (*Client) StorageGeneration

func (c *Client) StorageGeneration() (string, error)

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

func (c *Client) SyncHandlers() ([]*SyncInfo, error)

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

func (c *Client) TLSConfig() (*tls.Config, error)

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) Upload

func (c *Client) Upload(h *UploadHandle) (*PutResult, error)

type EnumerateOpts

type EnumerateOpts struct {
	After   string
	MaxWait time.Duration // how long to poll for (second granularity), waiting for any blob, or 0 for no limit
	Limit   int           // if non-zero, the max blobs to return
}

type HaveCache

type HaveCache interface {
	StatBlobCache(br *blobref.BlobRef) (size int64, ok bool)
	NoteBlobExists(br *blobref.BlobRef, size int64)
}

A HaveCache caches whether a remote blobserver has a blob.

type PutResult

type PutResult struct {
	BlobRef *blobref.BlobRef
	Size    int64
	Skipped bool // already present on blobserver
}

func (*PutResult) SizedBlobRef

func (pr *PutResult) SizedBlobRef() blobref.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
}

func (*Stats) String

func (s *Stats) String() string

type SyncInfo

type SyncInfo struct {
	From string
	To   string
}

SyncInfo holds the data that were acquired with a discovery and that are relevant to a syncHandler.

type UploadHandle

type UploadHandle struct {
	BlobRef  *blobref.BlobRef
	Size     int64 // or -1 if size isn't known
	Contents io.Reader
	Vivify   bool
}

func NewUploadHandleFromString

func NewUploadHandleFromString(data string) *UploadHandle

Jump to

Keyboard shortcuts

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