Asto stands for Abstract Storage, an abstraction over physical data storage system.
The main entity of the library is an interface com.artipie.asto.Storage, a contract
which requires to implement the following functionalities:
- put/get/delete operations
- transaction support
- list files in a directory
- check if a file/directory exists
- provide file metadata (size, checksums, type, etc.)
Dictionary used for ASTO:
Storage- key-value based storageKey- storage keys, could be converted to stringsContent- storage data, reactive publisher with optional size attributeSubStorage- isolated storage based on origin storage
The list of back-ends supported:
- FileStorage - file-system based storage, uses paths as keys, stores content in files
- S3Storage - uses S3 compatible HTTP web-server as storage, uses keys as names and blobs for content
- EtcdStorage - uses ETCD cluster as storage back-end
- InMemoryStorage - storage uses
HashMapto store data - RedisStorage - storage based on Redisson
This is the dependency you need:
<dependency>
<groupId>com.artipie</groupId>
<artifactId>asto-core</artifactId>
<version>[...]</version>
</dependency>The following dependency allows using RedisStorage:
<dependency>
<groupId>com.artipie</groupId>
<artifactId>asto-redis</artifactId>
<version>[...]</version>
</dependency>Read the Javadoc for more technical details.
If you have any question or suggestions, do not hesitate to create an issue
or contact us in Telegram.
Artipie roadmap.
The main entities here are:
Storageinterface provides API for key-value storageKeyrepresents storage keyContentrepresents storage binary value
Storage, Key and other entities are documented in javadoc.
Here is en example of how to create FileStorage, save and then read some data:
final Storage asto = new FileStorage(Path.of("/usr/local/example"));
final Key key = new Key.From("hello.txt");
asto.save(
key,
new Content.From("Hello world!".getBytes(StandardCharsets.UTF_8))
).thenCompose(
ignored -> asto.value(key)
).thenCompose(
val -> new PublisherAs(val).asciiString()
).thenAccept(
System.out::println
).join();In the example we created local text file /usr/local/example/hello.txt containing string "Hello world!",
then read and print it into console. Used classes:
Key.Fromis implementation of theKeyinterface, keys are strings, separated by/Content.FromimplementsContentinterface, allows to createContentinstances from byte arrays or publisher of ByteBuffer'sPublisherAsclass allows to fully readContentinto memory as byte arrays
Note, that Storage is asynchronous and always returns CompletableFutures as a result, use
future chains (thenAccept(), thenCompose() etc.) and call blocking methods get() or join()
when necessary.
Other storage implementations (S3Storage, InMemoryStorage, RedisStorage) can be used in the same way, only
constructors differ, here is an example of how to create S3Storage instance:
final Storage asto = new S3Storage(
S3AsyncClient.builder().credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create("accessKeyId", "secretAccessKey")
)
).build(),
"bucketName"
);To get more details about S3AsyncClient builder, check
Java S3 client docs.
Please read contributing rules.
Fork repository, make changes, send us a pull request. We will review
your changes and apply them to the master branch shortly, provided
they don't violate our quality standards. To avoid frustration, before
sending us your pull request please run full Maven build:
$ mvn clean install -Pqulice
To avoid build errors use Maven 3.2+.