コード例 #1
0
func (suite *ReleaseStoreLibrarySuite) createChunkResource(rel release.Release, name string, filler func(consumer chunk.Consumer)) {
	resource, _ := rel.NewResource(name, "")
	writer, _ := resource.AsSink()
	consumer := dosChunk.NewChunkConsumer(writer)
	filler(consumer)
	consumer.Finish()
}
コード例 #2
0
func (suite *DynamicChunkStoreSuite) createChunkProvider(filler func(consumer chunk.Consumer)) chunk.Provider {
	store := serial.NewByteStore()
	consumer := dos.NewChunkConsumer(store)
	filler(consumer)
	consumer.Finish()

	provider, _ := dos.NewChunkProvider(bytes.NewReader(store.Data()))

	return provider
}
コード例 #3
0
func (library *ReleaseStoreLibrary) serializeChunkStore(store chunk.Store) []byte {
	buffer := serial.NewByteStore()
	consumer := dosChunk.NewChunkConsumer(buffer)
	ids := store.IDs()

	for _, id := range ids {
		blockStore := store.Get(id)
		consumer.Consume(id, blockStore)
	}
	consumer.Finish()

	return buffer.Data()
}