Sources

The Source is what fuels your services with data. We try to implement the most popular data sources, though this list will be extended continuously.

File System

This is the one which comes with ressor-core library. In order to use it, call the appropriate method of the Ressor builder:

ressor.service(Clazz.class)
.fileSource("/etc/data/data.json")

You can also point to local classpath resources:

ressor.service(Clazz.class)
.fileSource("classpath:local/data.json")

HTTP

In order to use it, please add ressor-http-source library to your classpath.

It allows you to use Http/Https endpoints as a data source. You should use Http class as a factory builder:

ressor.service(Clazz.class)
.source(
Http.builder()
.pool(100, 120000)
.keepAlive(true)
.socketTimeout(5000)
.cacheControlStrategy(ETAG)
.build()
)
.resource(Http.url("https://ex.com/d.yaml"))
.translator(yaml())

In order to understand what cacheControlStrategy is, please refer the Reload Strategies section.

Under the hood, the Apache HttpClient is used.

Git

In order to use it, please add ressor-git-source library to your classpath.

It allows you to use any file in remote/local Git repository as a data source. You should use GitRepository class as a factory builder:

ressor.service(Service.class)
.source(
GitRepository.local()
.repositoryDirectory("/etc/myrepo")
.build()
)
.resource(
GitRepository.path("configs/prices.yaml",
"develop")
)

Or clone the remote one and use it as local

ressor.service(Service.class)
.source(
GitRepository.remote()
.repositoryUrl("https://github.com/mmathioudakis/geotopics.git")
.repositoryDirectory("/opt")
.build()
)
.resource(
GitRepository.path("data/firenze_venues.json",
"gh-pages")
)

By default, all cloned repositories are bare.

S3

In order to use it, please add ressor-s3-source library to your classpath.

You can use any file located on AWS S3 storage as your data source. For that, use S3 class for building source and resource location:

ressor.service(Service.class)
.source(S3.builder()
.credentials("access", "secret")
.region("eu-west-2")
.build()
)
.resource(S3.object("my-bucket", "data/items.json"))