Documentation ¶
Index ¶
- func IsBlobReferenceAttribute(attr string) bool
- func IsFulltextAttribute(attr string) bool
- func IsIndexedAttribute(attr string) bool
- type Claim
- type ClaimList
- type ClaimsItem
- type ClaimsRequest
- type ClaimsResponse
- type DescribeError
- type DescribeRequest
- func (dr *DescribeRequest) Describe(br *blobref.BlobRef, depth int)
- func (dr *DescribeRequest) DescribeSync(br *blobref.BlobRef) (*DescribedBlob, error)
- func (dr *DescribeRequest) DescribedBlobStr(blobstr string) *DescribedBlob
- func (dr *DescribeRequest) Result() (desmap map[string]*DescribedBlob, err error)
- type DescribeResponse
- type DescribedBlob
- func (b *DescribedBlob) ContentRef() (br *blobref.BlobRef, ok bool)
- func (b *DescribedBlob) Description() string
- func (b *DescribedBlob) DomID() string
- func (b *DescribedBlob) HasSecureLinkTo(other *blobref.BlobRef) bool
- func (b *DescribedBlob) Members() []*DescribedBlob
- func (b *DescribedBlob) PeerBlob(br *blobref.BlobRef) *DescribedBlob
- func (b *DescribedBlob) PermanodeFile() (path []*blobref.BlobRef, fi *FileInfo, ok bool)
- func (b *DescribedBlob) Title() string
- type DescribedPermanode
- type Edge
- type EdgeItem
- type EdgesRequest
- type EdgesResponse
- type EdgesToOpts
- type FileInfo
- type Handler
- func (sh *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error)
- func (sh *Handler) GetClaims(req *ClaimsRequest) (*ClaimsResponse, error)
- func (sh *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error)
- func (sh *Handler) GetRecentPermanodes(req *RecentRequest) (*RecentResponse, error)
- func (sh *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error)
- func (h *Handler) Index() Index
- func (sh *Handler) NewDescribeRequest() *DescribeRequest
- func (h *Handler) Owner() *blobref.BlobRef
- func (sh *Handler) ResolvePrefixHop(parent *blobref.BlobRef, prefix string) (child *blobref.BlobRef, err error)
- func (sh *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type IGetRecentPermanodes
- type ImageInfo
- type Index
- type MetaMap
- type Path
- type PermanodeByAttrRequest
- type RecentItem
- type RecentRequest
- type RecentResponse
- type Result
- type Results
- type SignerAttrValueResponse
- type SignerPathsItem
- type SignerPathsRequest
- type SignerPathsResponse
- type WithAttrItem
- type WithAttrRequest
- type WithAttrResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBlobReferenceAttribute ¶
IsBlobReferenceAttribute returns whether attr is an attribute whose value is a blob reference (e.g. camliMember) and thus something the indexers should keep inverted indexes on for parent/child-type relationships.
func IsFulltextAttribute ¶
func IsIndexedAttribute ¶
TODO(bradfitz): rename this? This is really about signer-attr-value (PermanodeOfSignerAttrValue), and not about indexed attributes in general.
Types ¶
type Claim ¶
type Claim struct {
BlobRef, Signer, Permanode *blobref.BlobRef
Date time.Time
Type string // "set-attribute", "add-attribute", etc
// If an attribute modification
Attr, Value string
}
TODO: move this to schema or something?
type ClaimsItem ¶
type ClaimsItem struct { BlobRef *blobref.BlobRef `json:"blobref"` Signer *blobref.BlobRef `json:"signer"` Permanode *blobref.BlobRef `json:"permanode"` Date types.Time3339 `json:"date"` Type string `json:"type"` Attr string `json:"attr,omitempty"` Value string `json:"value,omitempty"` }
A ClaimsItem is an item returned from $searchRoot/camli/search/claims.
type ClaimsRequest ¶
ClaimsRequest is a request to get a ClaimsResponse.
type ClaimsResponse ¶
type ClaimsResponse struct {
Claims []*ClaimsItem `json:"claims"`
}
ClaimsResponse is the JSON response from $searchRoot/camli/search/claims.
type DescribeError ¶
func (DescribeError) Error ¶
func (de DescribeError) Error() string
type DescribeRequest ¶
type DescribeRequest struct {
// contains filtered or unexported fields
}
func (*DescribeRequest) Describe ¶
func (dr *DescribeRequest) Describe(br *blobref.BlobRef, depth int)
func (*DescribeRequest) DescribeSync ¶
func (dr *DescribeRequest) DescribeSync(br *blobref.BlobRef) (*DescribedBlob, error)
func (*DescribeRequest) DescribedBlobStr ¶
func (dr *DescribeRequest) DescribedBlobStr(blobstr string) *DescribedBlob
Given a blobref string returns a Description or nil. dr may be nil itself.
func (*DescribeRequest) Result ¶
func (dr *DescribeRequest) Result() (desmap map[string]*DescribedBlob, err error)
Result waits for all outstanding lookups to complete and returns the map of blobref (strings) to their described results. The returned error is non-nil if any errors occured, and will be of type DescribeError.
type DescribeResponse ¶
type DescribeResponse struct {
Meta MetaMap `json:"meta"`
}
DescribeResponse is the JSON response from $searchRoot/camli/search/describe.
type DescribedBlob ¶
type DescribedBlob struct { Request *DescribeRequest `json:"-"` BlobRef *blobref.BlobRef `json:"blobRef"` MIMEType string `json:"mimeType"` CamliType string `json:"camliType"` Size int64 `json:"size,"` // if camliType "permanode" Permanode *DescribedPermanode `json:"permanode,omitempty"` // if camliType "file" File *FileInfo `json:"file,omitempty"` // if camliType "directory" Dir *FileInfo `json:"dir,omitempty"` // if camliType "file", and File.IsImage() Image *ImageInfo `json:"image,omitempty"` Thumbnail string `json:"thumbnailSrc,omitempty"` ThumbnailWidth int `json:"thumbnailWidth,omitempty"` ThumbnailHeight int `json:"thumbnailHeight,omitempty"` // Stub is set if this is not loaded, but referenced. Stub bool `json:"-"` }
func (*DescribedBlob) ContentRef ¶
func (b *DescribedBlob) ContentRef() (br *blobref.BlobRef, ok bool)
func (*DescribedBlob) Description ¶
func (b *DescribedBlob) Description() string
func (*DescribedBlob) DomID ¶
func (b *DescribedBlob) DomID() string
func (*DescribedBlob) HasSecureLinkTo ¶
func (b *DescribedBlob) HasSecureLinkTo(other *blobref.BlobRef) bool
HasSecureLinkTo returns true if there's a valid link from this blob to the other blob. This is used in access control (hence the somewhat redundant "Secure" in the name) and should be paranoid against e.g. random user/attacker-control attributes making links to other blobs.
TODO: don't linear scan here. rewrite this in terms of ResolvePrefixHop, passing down some policy perhaps? or maybe that's enough.
func (*DescribedBlob) Members ¶
func (b *DescribedBlob) Members() []*DescribedBlob
func (*DescribedBlob) PeerBlob ¶
func (b *DescribedBlob) PeerBlob(br *blobref.BlobRef) *DescribedBlob
PeerBlob returns a DescribedBlob for the provided blobref.
Unlike DescribedBlobStr, the returned DescribedBlob is never nil.
If the blob was never loaded along with the the receiver (or if the receiver is nil), a stub DescribedBlob is returned with its Stub field set true.
func (*DescribedBlob) PermanodeFile ¶
func (b *DescribedBlob) PermanodeFile() (path []*blobref.BlobRef, fi *FileInfo, ok bool)
PermanodeFile returns the blobref path from this permanode to its File camliContent, else (nil, false)
func (*DescribedBlob) Title ¶
func (b *DescribedBlob) Title() string
type DescribedPermanode ¶
type Edge ¶
type EdgesRequest ¶
EdgesRequest is a request to get an EdgesResponse.
type EdgesResponse ¶
type EdgesResponse struct { ToRef *blobref.BlobRef `json:"toRef"` EdgesTo []*EdgeItem `json:"edgesTo"` }
EdgesResponse is the JSON response from $searchRoot/camli/search/edgesto.
type EdgesToOpts ¶
type EdgesToOpts struct {
Max int
}
type FileInfo ¶
type FileInfo struct { FileName string `json:"fileName"` // Size is the size of files. It is not set for directories. Size int64 `json:"size"` // MIMEType may be set for files, but never for directories. MIMEType string `json:"mimeType,omitempty"` // Time is the earliest of any modtime, creation time, or EXIF // original/modification times found. It may be omitted (zero) // if unknown. Time *types.Time3339 `json:"time,omitempty"` // ModTime is the latest of any modtime, creation time, or EXIF // original/modification times found. If ModTime doesn't differ // from Time, ModTime is omitted (zero). ModTime *types.Time3339 `json:"modTime,omitempty"` }
FileInfo describes a file or directory.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) EdgesTo ¶
func (sh *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error)
EdgesTo returns edges that reference req.RefTo. It filters out since-deleted permanode edges.
func (*Handler) GetClaims ¶
func (sh *Handler) GetClaims(req *ClaimsRequest) (*ClaimsResponse, error)
GetClaims returns the claims on req.Permanode signed by sh.owner.
func (*Handler) GetPermanodesWithAttr ¶
func (sh *Handler) GetPermanodesWithAttr(req *WithAttrRequest) (*WithAttrResponse, error)
GetPermanodesWithAttr returns permanodes with attribute req.Attr having the req.Value as a value. See WithAttrRequest for more details about the query.
func (*Handler) GetRecentPermanodes ¶
func (sh *Handler) GetRecentPermanodes(req *RecentRequest) (*RecentResponse, error)
GetRecentPermanodes returns recently-modified permanodes.
func (*Handler) GetSignerPaths ¶
func (sh *Handler) GetSignerPaths(req *SignerPathsRequest) (*SignerPathsResponse, error)
GetSignerPaths returns paths with a target of req.Target.
func (*Handler) NewDescribeRequest ¶
func (sh *Handler) NewDescribeRequest() *DescribeRequest
NewDescribeRequest returns a new DescribeRequest holding the state of blobs and their summarized descriptions. Use DescribeBlob one or more times before calling Result.
func (*Handler) Owner ¶
TODO: figure out a plan for an owner having multiple active public keys, or public key rotation
type IGetRecentPermanodes ¶
type IGetRecentPermanodes interface { // GetRecentPermanodes returns recently-modified permanodes. // This is a higher-level query returning more metadata than the index.GetRecentPermanodes, // which only scans the blobrefs but doesn't return anything about the permanodes. // TODO: rename this one? GetRecentPermanodes(*RecentRequest) (*RecentResponse, error) }
IGetRecentPermanodes is the interface encapsulating the GetRecentPermanodes query.
type ImageInfo ¶
type ImageInfo struct { // Width is the visible width of the image (after any necessary EXIF rotation). Width int `json:"width"` // Height is the visible height of the image (after any necessary EXIF rotation). Height int `json:"height"` }
ImageInfo describes an image file.
type Index ¶
type Index interface { // dest must be closed, even when returning an error. // limit is <= 0 for default. smallest possible default is 0 GetRecentPermanodes(dest chan *Result, owner *blobref.BlobRef, limit int) error // SearchPermanodes finds permanodes matching the provided // request and sends unique permanode blobrefs to dest. // In particular, if request.FuzzyMatch is true, a fulltext // search is performed (if supported by the attribute(s)) // instead of an exact match search. // If request.Query is blank, the permanodes which have // request.Attribute as an attribute (regardless of its value) // are searched. // Additionally, if request.Attribute is blank, all attributes // are searched (as fulltext), otherwise the search is // restricted to the named attribute. // // dest is always closed, regardless of the error return value. SearchPermanodesWithAttr(dest chan<- *blobref.BlobRef, request *PermanodeByAttrRequest) error GetOwnerClaims(permaNode, owner *blobref.BlobRef) (ClaimList, error) // os.ErrNotExist should be returned if the blob isn't known GetBlobMIMEType(blob *blobref.BlobRef) (mime string, size int64, err error) // ExistingFileSchemas returns 0 or more blobrefs of "bytes" // (TODO(bradfitz): or file?) schema blobs that represent the // bytes of a file given in bytesRef. The file schema blobs // returned are not guaranteed to reference chunks that still // exist on the blobservers, though. It's purely a hint for // clients to avoid uploads if possible. Before re-using any // returned blobref they should be checked. // // Use case: a user drag & drops a large file onto their // browser to upload. (imagine that "large" means anything // larger than a blobserver's max blob size) JavaScript can // first SHA-1 the large file locally, then send the // wholeFileRef to this call and see if they'd previously // uploaded the same file in the past. If so, the upload // can be avoided if at least one of the returned schemaRefs // can be validated (with a validating HEAD request) to still // all exist on the blob server. ExistingFileSchemas(wholeFileRef *blobref.BlobRef) (schemaRefs []*blobref.BlobRef, err error) // Should return os.ErrNotExist if not found. GetFileInfo(fileRef *blobref.BlobRef) (*FileInfo, error) // Should return os.ErrNotExist if not found. GetImageInfo(fileRef *blobref.BlobRef) (*ImageInfo, error) // Given an owner key, a camliType 'claim', 'attribute' name, // and specific 'value', find the most recent permanode that has // a corresponding 'set-attribute' claim attached. // Returns os.ErrNotExist if none is found. // TODO(bradfitz): ErrNotExist here is a weird error message ("file" not found). change. // Only attributes white-listed by IsIndexedAttribute are valid. PermanodeOfSignerAttrValue(signer *blobref.BlobRef, attr, val string) (*blobref.BlobRef, error) // PathsOfSignerTarget queries the index about "camliPath:" // URL-dispatch attributes. // // It returns a list of all the path claims that have been signed // by the provided signer and point at the given target. // // This is used when editing a permanode, to figure work up // the name resolution tree backwards ultimately to a // camliRoot permanode (which should know its base URL), and // then the complete URL(s) of a target can be found. PathsOfSignerTarget(signer, target *blobref.BlobRef) ([]*Path, error) // All Path claims for (signer, base, suffix) PathsLookup(signer, base *blobref.BlobRef, suffix string) ([]*Path, error) // Most recent Path claim for (signer, base, suffix) as of // provided time 'at', or most recent if 'at' is nil. PathLookup(signer, base *blobref.BlobRef, suffix string, at time.Time) (*Path, error) // EdgesTo finds references to the provided ref. // // For instance, if ref is a permanode, it might find the parent permanodes // that have ref as a member. // Or, if ref is a static file, it might find static directories which contain // that file. // This is a way to go "up" or "back" in a hierarchy. // // opts may be nil to accept the defaults. EdgesTo(ref *blobref.BlobRef, opts *EdgesToOpts) ([]*Edge, error) }
type MetaMap ¶
type MetaMap map[string]*DescribedBlob
A MetaMap is a map from blobref to a DescribedBlob.
type PermanodeByAttrRequest ¶
type PermanodeByAttrRequest struct { Signer *blobref.BlobRef // Attribute to search. currently supported: "tag", "title" // If FuzzyMatch is set, this can be blank to search all // attributes. Attribute string // The attribute value to find exactly (or roughly, if // FuzzyMatch is set) // If blank, the permanodes with Attribute as an attribute // (set to any value) are searched. Query string FuzzyMatch bool // by default, an exact match is required MaxResults int // optional max results }
type RecentItem ¶
type RecentItem struct { BlobRef *blobref.BlobRef `json:"blobref"` ModTime types.Time3339 `json:"modtime"` Owner *blobref.BlobRef `json:"owner"` }
A RecentItem is an item returned from $searchRoot/camli/search/recent in the "recent" list.
type RecentRequest ¶
type RecentRequest struct { N int // if zero, default number of results Before time.Time // if zero, now ThumbnailSize int // if zero, no thumbnails }
RecentRequest is a request to get a RecentResponse.
func (*RecentRequest) URLSuffix ¶
func (r *RecentRequest) URLSuffix() string
type RecentResponse ¶
type RecentResponse struct { Recent []*RecentItem `json:"recent"` Meta MetaMap `json:"meta"` Error string `json:"error,omitempty"` ErrorType string `json:"errorType,omitempty"` }
RecentResponse is the JSON response from $searchRoot/camli/search/recent.
func (*RecentResponse) Err ¶
func (r *RecentResponse) Err() error
type Results ¶
type Results []*Result
Results exists mostly for debugging, to provide a String method on a slice of Result.
type SignerAttrValueResponse ¶
type SignerAttrValueResponse struct { Permanode *blobref.BlobRef `json:"permanode"` Meta MetaMap `json:"meta"` }
SignerAttrValueResponse is the JSON response to $search/camli/search/signerattrvalue
type SignerPathsItem ¶
type SignerPathsItem struct { ClaimRef *blobref.BlobRef `json:"claimRef"` BaseRef *blobref.BlobRef `json:"baseRef"` Suffix string `json:"suffix"` }
A SignerPathsItem is an item returned from $searchRoot/camli/search/signerpaths.
type SignerPathsRequest ¶
SignerPathsRequest is a request to get a SignerPathsResponse.
type SignerPathsResponse ¶
type SignerPathsResponse struct { Paths []*SignerPathsItem `json:"paths"` Meta MetaMap `json:"meta"` }
SignerPathsResponse is the JSON response from $searchRoot/camli/search/signerpaths.
type WithAttrItem ¶
A WithAttrItem is an item returned from $searchRoot/camli/search/permanodeattr.
type WithAttrRequest ¶
type WithAttrRequest struct { N int // max number of results Signer *blobref.BlobRef // if nil, search will return index.ErrNotFound // Requested attribute. If blank, all attributes are searched (for Value) // as fulltext. Attr string // Value of the requested attribute. If blank, permanodes which have // request.Attribute as an attribute are searched. Value string Fuzzy bool // fulltext search (if supported). ThumbnailSize int // if zero, no thumbnails }
WithAttrRequest is a request to get a WithAttrResponse.
type WithAttrResponse ¶
type WithAttrResponse struct { WithAttr []*WithAttrItem `json:"withAttr"` Meta MetaMap `json:"meta"` }
WithAttrResponse is the JSON response from $searchRoot/camli/search/permanodeattr.