Example #1
0
func newService(t *testing.T, entries []*spb.Entry) *GraphStoreService {
	gs := inmemory.Create()

	for req := range graphstore.BatchWrites(channelEntries(entries), 64) {
		if err := gs.Write(ctx, req); err != nil {
			t.Fatalf("Failed to write entries: %v", err)
		}
	}
	return NewGraphStoreService(gs)
}
Example #2
0
	"strings"
	"syscall"

	"kythe.io/kythe/go/services/graphstore"
	"kythe.io/kythe/go/storage/inmemory"

	"golang.org/x/net/context"
)

// Handler returns a graphstore.Service based on the given specification.
// See also: Register(string, Handler).
type Handler func(spec string) (graphstore.Service, error)

var (
	handlers = map[string]Handler{
		"in-memory": func(_ string) (graphstore.Service, error) { return inmemory.Create(), nil },
	}
	defaultHandlerKind string
)

// Register exposes the given Handler to ParseGraphStore.  Each string starting
// with kind+":" will be passed to the given Handler.  A kind can only be
// registered once.
func Register(kind string, h Handler) {
	if _, exists := handlers[kind]; exists {
		log.Fatalf("gsutil Handler for kind %q already exists", kind)
	}
	handlers[kind] = h
}

// RegisterDefault gives ParseGraphStore a fallback kind if not given any