filetree

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2015 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Overview

Package filetree defines the filetree Service interface and a simple in-memory implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHTTPHandlers

func RegisterHTTPHandlers(ctx context.Context, ft Service, mux *http.ServeMux)

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 NewMap

func NewMap() *Map

NewMap returns an empty filetree map.

func (*Map) AddFile

func (m *Map) AddFile(file *spb.VName)

AddFile adds the given file VName to m.

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.

func (*Map) Populate

func (m *Map) Populate(ctx context.Context, gs graphstore.Service) error

Populate adds each file node in gs to m.

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

GRPC returns a filetree Service backed by a FileTreeServiceClient.

func WebClient

func WebClient(addr string) Service

WebClient returns an filetree Service based on a remote web server.

Jump to

Keyboard shortcuts

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