Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a local directory as an event source (close #42)
- Loading branch information
Showing
10 changed files
with
130 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# The minimum required config options for loading from kinesis | ||
{ | ||
"input": { | ||
"type": "LocalFs" | ||
"path": "/tmp/example" | ||
} | ||
|
||
"output" : { | ||
"type": "Postgres" | ||
"host": "localhost" | ||
"database": "snowplow" | ||
"username": "postgres" | ||
"password": "mysecretpassword" | ||
"schema": "atomic" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...loader/src/main/scala/com/snowplowanalytics/snowplow/postgres/config/ConfigPreCheck.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.snowplowanalytics.snowplow.postgres.config | ||
|
||
import cats.effect.Sync | ||
import cats.data.EitherT | ||
import cats.implicits._ | ||
|
||
import java.nio.file.{Path, Files} | ||
import com.snowplowanalytics.snowplow.postgres.config.LoaderConfig.Source.LocalFs | ||
|
||
import scala.util.Try | ||
|
||
/** | ||
* Check if given configuration meets necessary requirements | ||
*/ | ||
object ConfigPreCheck { | ||
def apply[F[_]: Sync](cli: Cli[F]): EitherT[F, String, Cli[F]] = | ||
EitherT(Sync[F].delay { | ||
cli.config.input match { | ||
// If configuration is for local source, check if given path exists | ||
case LocalFs(path) => | ||
Either.fromTry(Try { | ||
Files.exists(Path.of("/" + path.toString())) | ||
}).flatMap { exists => | ||
if (exists) cli.asRight | ||
else "Path does not exist".asLeft | ||
}.leftMap(_.toString) | ||
case _ => cli.asRight | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters