Java API - gquintana/beepbeep GitHub Wiki
Beep beep is published in Maven Central repositories
<dependency>
<groupId>com.github.gquintana.beepbeep</groupId>
<artifactId>beepbeep</artifactId>
<version>0.1.1</version>
</dependency>
A Pipeline
is a chain of event consumers starting by ScriptScanner
which produces ScriptStartEvent
s for each Script
. The Pipeline
is executed with its run
method.
A Pipeline
is mostly immutable and is created from a PipelineBuilder
SqlPipelineBuilder pipelineBuilder = new SqlPipelineBuilder()
.withUrl("jdbc:mysql://localhost:3306/mydb")
.withFilesScriptScanner("scripts/*.sql");
try(SqlPipeline pipeline = pipelineBuilder.build()) {
pipeline.run();
}
The pipeline may end with custom consumer which receives line execution results. It
A ScriptScanner
aims at finding Script
s on the file system (FileScriptScanner
) or the classpath (ResourceScriptScanner
).
ScriptScanner
can be created from the ScriptScanners
or ScriptScannerFactories
classes.
The later just adds curryfication over the former.
There are many implementations:
-
resource
,resources
find scripts by scanning Jars and folders on class path -
file
,files
find scripts by file system (be sure to have the appropriate permissions) -
composite
can mix and match multipleScriptScanner
in a single one -
scheme
uses a prefix scheme (classpath:
, 'file:
) to determine the appropriate implementation
The file and resources ScriptScanner
s can use Java predicates to select scripts or name globbing.
Name globbing uses the usual Ant syntax:
base/folder/**/script*.ext
**
means any number of directories between folder
and script-12.ext
. It's a recursive search.
The ScriptStore
is basically a DAO/repository to write ran scripts into a database.
There multiple implementations for different backends: SqlScriptStore
, ElasticsearchScriptStore
, MemoryScriptStore
(for testing purposes)....
ScriptStore
s have a prepare
method in charge of creating the table/index/...,
this method should be idempotent since it's ran each time the pipeline starts.