-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: the initial provisioning route (#7)
* Add SOLR client library allowing basic queries, updates and schema changes * Allow solr payloads encoded by borer; adding discriminator fields for case classes * Add search module using solr library to search and insert projects * Combine solr and redis in search-provision module implementing the whole route: consuming redis messages, avro decoding and pushing to slr * Adds test setup that starts single instances of solr and redis for all tests to share --------- Co-authored-by: Eike Kettner <[email protected]>
- Loading branch information
Showing
80 changed files
with
3,030 additions
and
204 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
3 changes: 3 additions & 0 deletions
3
modules/avro-codec/src/main/scala/io/renku/avro/codec/all.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,3 @@ | ||
package io.renku.avro.codec | ||
|
||
object all extends encoders.all with decoders.all |
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
26 changes: 26 additions & 0 deletions
26
modules/avro-codec/src/main/scala/io/renku/avro/codec/json/AvroJsonDecoder.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,26 @@ | ||
package io.renku.avro.codec.json | ||
|
||
import io.renku.avro.codec.{AvroDecoder, AvroReader} | ||
import org.apache.avro.Schema | ||
import scodec.bits.ByteVector | ||
|
||
import scala.util.Try | ||
|
||
trait AvroJsonDecoder[A]: | ||
def decode(json: ByteVector): Either[String, A] | ||
final def map[B](f: A => B): AvroJsonDecoder[B] = | ||
AvroJsonDecoder(this.decode.andThen(_.map(f))) | ||
final def emap[B](f: A => Either[String, B]): AvroJsonDecoder[B] = | ||
AvroJsonDecoder(this.decode.andThen(_.flatMap(f))) | ||
|
||
object AvroJsonDecoder: | ||
def apply[A](using d: AvroJsonDecoder[A]): AvroJsonDecoder[A] = d | ||
|
||
def apply[A](f: ByteVector => Either[String, A]): AvroJsonDecoder[A] = | ||
(json: ByteVector) => f(json) | ||
|
||
def create[A: AvroDecoder](schema: Schema): AvroJsonDecoder[A] = { json => | ||
Try(AvroReader(schema).readJson[A](json)).toEither.left | ||
.map(_.getMessage) | ||
.flatMap(_.headOption.toRight(s"Empty json")) | ||
} |
32 changes: 32 additions & 0 deletions
32
modules/avro-codec/src/main/scala/io/renku/avro/codec/json/AvroJsonEncoder.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,32 @@ | ||
package io.renku.avro.codec.json | ||
|
||
import io.renku.avro.codec.{AvroEncoder, AvroWriter} | ||
import io.renku.avro.codec.encoders.all.given | ||
import org.apache.avro.{Schema, SchemaBuilder} | ||
import scodec.bits.ByteVector | ||
|
||
trait AvroJsonEncoder[A]: | ||
def encode(value: A): ByteVector | ||
final def contramap[B](f: B => A): AvroJsonEncoder[B] = | ||
AvroJsonEncoder(f.andThen(this.encode)) | ||
|
||
object AvroJsonEncoder: | ||
def apply[A](using e: AvroJsonEncoder[A]): AvroJsonEncoder[A] = e | ||
|
||
def apply[A](f: A => ByteVector): AvroJsonEncoder[A] = | ||
(a: A) => f(a) | ||
|
||
def create[A: AvroEncoder](schema: Schema): AvroJsonEncoder[A] = | ||
a => AvroWriter(schema).writeJson(Seq(a)) | ||
|
||
given AvroJsonEncoder[String] = | ||
create[String](SchemaBuilder.builder().stringType()) | ||
|
||
given AvroJsonEncoder[Long] = | ||
create[Long](SchemaBuilder.builder().longType()) | ||
|
||
given AvroJsonEncoder[Int] = | ||
create[Int](SchemaBuilder.builder().intType()) | ||
|
||
given AvroJsonEncoder[Double] = | ||
create[Double](SchemaBuilder.builder().doubleType()) |
Oops, something went wrong.