Documentation ¶
Overview ¶
Package filetree defines the filetree Service interface and a simple in-memory implementation.
Index ¶
- func RegisterHTTPHandlers(ctx context.Context, ft Service, mux *http.ServeMux)
- type Map
- func (m *Map) AddFile(file *spb.VName)
- func (m *Map) CorpusRoots(ctx context.Context, req *ftpb.CorpusRootsRequest) (*ftpb.CorpusRootsReply, error)
- func (m *Map) Directory(ctx context.Context, req *ftpb.DirectoryRequest) (*ftpb.DirectoryReply, error)
- func (m *Map) Populate(ctx context.Context, gs graphstore.Service) error
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHTTPHandlers ¶
RegisterHTTPHandlers registers JSON HTTP handlers with mux using the given filetree Service. The following methods with be exposed:
GET /corpusRoots Response: JSON encoded filetree.CorpusRootsReply GET /dir Request: JSON encoded filetree.DirectoryRequest Response: JSON encoded filetree.DirectoryReply
Note: /corpusRoots and /dir will return their responses as serialized protobufs if the "proto" query parameter is set.
Types ¶
type Map ¶
type Map struct { // corpus -> root -> dirPath -> DirectoryReply M map[string]map[string]map[string]*ftpb.DirectoryReply }
Map is a FileTree backed by an in-memory map.
func (*Map) CorpusRoots ¶
func (m *Map) CorpusRoots(ctx context.Context, req *ftpb.CorpusRootsRequest) (*ftpb.CorpusRootsReply, error)
CorpusRoots implements part of the filetree.Service interface.
func (*Map) Directory ¶
func (m *Map) Directory(ctx context.Context, req *ftpb.DirectoryRequest) (*ftpb.DirectoryReply, error)
Directory implements part of the filetree.Service interface.
type Service ¶
type Service interface { // Directory returns the contents of the directory at the given corpus/root/path. Directory(context.Context, *ftpb.DirectoryRequest) (*ftpb.DirectoryReply, error) // CorpusRoots returns a map from corpus to known roots. CorpusRoots(context.Context, *ftpb.CorpusRootsRequest) (*ftpb.CorpusRootsReply, error) }
Service provides an interface to explore a tree of VName files. TODO(schroederc): add Context argument to interface methods
func GRPC ¶
func GRPC(c ftpb.FileTreeServiceClient) Service
GRPC returns a filetree Service backed by a FileTreeServiceClient.