Пример #1
0
func (s *server) CompactBlock(ctx context.Context, request *oproto.CompactBlockRequest) (*oproto.CompactBlockResponse, error) {
	logCtx := openinstrument.LogContext(ctx)
	block, err := s.ds.GetBlock(request.Block.Id, request.Block.EndKey)
	if err != nil {
		return nil, err
	}
	if err = block.Compact(logCtx); err != nil {
		return nil, err
	}
	log.Printf("Log:\n%s", openinstrument.StringLog(logCtx))
	return &oproto.CompactBlockResponse{Block: block.ToProto()}, nil
}
Пример #2
0
// Open opens a datastore at the supplied path.
func Open(ctx context.Context, path string) *Datastore {
	ds := &Datastore{
		Path:   path,
		blocks: make(map[string]*Block),
	}

	logCtx := openinstrument.LogContext(ctx)
	if !ds.readBlocks(logCtx) {
		return nil
	}

	go ds.background(ctx)
	return ds
}