Skip to content

Commit

Permalink
Fix #23
Browse files Browse the repository at this point in the history
  • Loading branch information
dacr committed May 21, 2024
1 parent 1a6aed7 commit d5aa92c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SearchServiceLive(elasticOperations: ElasticOperations, config: SearchServ
def publish(photos: Chunk[Photo]): IO[SearchServiceIssue, Chunk[Photo]] = {
elasticOperations
.upsert(config.indexPrefix, photos.map(p => SaoPhoto.fromPhoto(p)))(_.timestamp, _.id)
.when(config.enabled)
.logError("couldń't upsert some or all photos from the given chunk of photos")
.mapError(errs => SearchServiceIssue(s"Couldn't upsert", errs))
.map(_ => photos)
Expand All @@ -45,6 +46,8 @@ class SearchServiceLive(elasticOperations: ElasticOperations, config: SearchServ
override def unpublish(photoId: PhotoId, photoTimestamp: OffsetDateTime): IO[SearchServiceIssue, Unit] = {
elasticOperations
.delete(config.indexPrefix, photoId.id.toString, photoTimestamp)
.when(config.enabled)
.map(_ => ())
.logError(s"Couldn't unpublish $photoId $photoTimestamp")
.mapError(err => SearchServiceIssue(s"Couldn't unpublish $photoId $photoTimestamp", err :: Nil))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import zio.config.*
import zio.config.magnolia.*

case class SearchServiceConfig(
enabled: Boolean,
elasticUrl: String, // WARNING : ELASTIC_URL DEFAULT PORT IS 9200 !! (and not 80 or 443) SO BE EXPLICIT
elasticUrlTrust: Boolean, // shall we trust self-signed ssl certificates
elasticUsername: Option[String],
Expand Down
2 changes: 2 additions & 0 deletions user-interfaces/cli/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sotohp {
ignore-mask = ${?PHOTOS_SEARCH_IGNORE_MASK}
}
search-service {
enabled = true
enabled = ${?PHOTOS_ELASTIC_ENABLED}
elastic-url = "http://127.0.0.1:9200"
elastic-url = ${?PHOTOS_ELASTIC_URL}
elastic-url-trust = false
Expand Down

0 comments on commit d5aa92c

Please sign in to comment.