Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup search api #364

Merged
merged 4 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ val commonSettings = Seq(

lazy val core = project
.in(file("modules/core"))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
name := "core",
commonSettings,
libraryDependencies ++= Seq(
catsCore
catsCore,
smithy4sCore
)
)

Expand All @@ -54,7 +56,8 @@ lazy val elastic = project
)
.dependsOn(core)

lazy val api = (project in file("modules/api"))
lazy val api = project
.in(file("modules/api"))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
name := "api",
Expand All @@ -67,7 +70,9 @@ lazy val api = (project in file("modules/api"))
)
.dependsOn(core)

lazy val ingestor = (project in file("modules/ingestor"))
lazy val ingestor = project
.in(file("modules/ingestor"))
.enablePlugins(Smithy4sCodegenPlugin)
.settings(
name := "ingestor",
commonSettings,
Expand All @@ -83,6 +88,7 @@ lazy val ingestor = (project in file("modules/ingestor"))
declineCatsEffect,
ducktape,
cirisCore,
smithy4sCore,
smithy4sJson,
jsoniterCore,
jsoniterMacro,
Expand All @@ -102,9 +108,10 @@ lazy val ingestor = (project in file("modules/ingestor"))
Compile / run / fork := true
)
.enablePlugins(JavaAppPackaging)
.dependsOn(elastic, api)
.dependsOn(elastic, core)

lazy val client = (project in file("modules/client"))
lazy val client = project
.in(file("modules/client"))
.settings(
name := "client",
commonSettings,
Expand All @@ -117,7 +124,8 @@ lazy val client = (project in file("modules/client"))
)
.dependsOn(api, core)

lazy val app = (project in file("modules/app"))
lazy val app = project
.in(file("modules/app"))
.settings(
name := "lila-search",
commonSettings,
Expand All @@ -139,22 +147,21 @@ lazy val app = (project in file("modules/app"))
logback,
otel4sMetricts,
otel4sSdk,
otel4sPrometheusExporter,
weaver,
testContainers
otel4sPrometheusExporter
),
Compile / run / fork := true
)
.enablePlugins(JavaAppPackaging)
.dependsOn(api, elastic)

val e2e = (project in file("modules/e2e"))
val e2e = project
.in(file("modules/e2e"))
.settings(
publish := {},
publish / skip := true,
libraryDependencies ++= Seq(weaver)
libraryDependencies ++= Seq(testContainers, weaver)
)
.dependsOn(client, app)
.dependsOn(client, app, ingestor)

lazy val root = project
.in(file("."))
Expand Down
265 changes: 13 additions & 252 deletions modules/api/src/main/smithy/search.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ use smithy4s.meta#adt
use smithy.api#default
use smithy.api#jsonName

use lila.search.core#Ids
use lila.search.core#FromInt
use lila.search.core#SizeInt
use lila.search.core#PlayerIds
use lila.search.core#Strings
use lila.search.core#IndexString
use lila.search.core#DateTime

@simpleRestJson
service SearchService {
version: "3.0.0"
operations: [Search, Count, DeleteById, DeleteByIds, Mapping, Refresh, Store, StoreBulkForum, StoreBulkGame, StoreBulkStudy, StoreBulkTeam]
operations: [Search, Count]
}

@readonly
Expand Down Expand Up @@ -55,155 +63,6 @@ operation Count {
errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/delete/id/{index}/{id}", code: 200)
operation DeleteById {
input := {
@required
@httpLabel
index: IndexString

@required
@httpLabel
id: String
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/delete/ids/{index}", code: 200)
operation DeleteByIds {
input := {
@required
@httpLabel
index: IndexString

@required
ids: Ids
}
errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/mapping/{index}", code: 200)
operation Mapping {
input := {
@required
@httpLabel
index: IndexString
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/refresh/{index}", code: 200)
operation Refresh {
input := {
@required
@httpLabel
index: IndexString
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/store/{id}", code: 200)
operation Store {
input := {

@httpLabel
@required
id: String

@required
source: Source
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/store-bulk/forum", code: 200)
operation StoreBulkForum {
input := {
@required
sources: ForumSources
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/store-bulk/game", code: 200)
operation StoreBulkGame {
input := {
@required
sources: GameSources
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/store-bulk/study", code: 200)
operation StoreBulkStudy {
input := {
@required
sources: StudySources
}

errors: [InternalServerError]
}

@http(method: "POST", uri: "/api/store-bulk/team", code: 200)
operation StoreBulkTeam {
input := {
@required
sources: TeamSources
}

errors: [InternalServerError]
}

list ForumSources {
member: ForumSourceWithId
}

list GameSources {
member: GameSourceWithId
}

list StudySources {
member: StudySourceWithId
}

list TeamSources {
member: TeamSourceWithId
}

structure ForumSourceWithId {
@required
id: String
@required
source: ForumSource
}

structure TeamSourceWithId {
@required
id: String
@required
source: TeamSource
}

structure StudySourceWithId {
@required
id: String
@required
source: StudySource
}

structure GameSourceWithId {
@required
id: String
@required
source: GameSource
}

structure Forum {
@required
text: String
Expand Down Expand Up @@ -282,108 +141,10 @@ union Query {
team: Team
}

structure ForumSource {
@required
@jsonName("bo")
body: String
@required
@jsonName("to")
topic: String
@required
@jsonName("ti")
topicId: String
@jsonName("au")
author: String
@required
@jsonName("tr")
troll: Boolean
/// time in milliseconds
@required
@jsonName("da")
date: Long
}

structure GameSource {
@required
@jsonName("s")
status: Integer
@required
@jsonName("t")
turns: Integer
@required
@jsonName("r")
rated: Boolean
@required
@jsonName("p")
perf: Integer
@jsonName("u")
uids: PlayerIds
@jsonName("w")
winner: String
@jsonName("o")
loser: String
@error("server")
@httpError(500)
structure InternalServerError {
@required
@jsonName("c")
winnerColor: Integer
@jsonName("a")
averageRating: Integer
@jsonName("i")
ai: Integer
@required
@jsonName("d")
date: DateTime
@jsonName("l")
duration: Integer
@jsonName("ct")
clockInit: Integer
@jsonName("ci")
clockInc: Integer
@required
@jsonName("n")
analysed: Boolean
@jsonName("wu")
whiteUser: String
@jsonName("bu")
blackUser: String
@jsonName("so")
source: Integer
message: String
}

structure StudySource {
@required
name: String
@required
owner: String
@required
members: PlayerIds
@required
chapterNames: String

@required
chapterTexts: String
@default
topics: Strings
@required
likes: Integer
@required
public: Boolean
}

structure TeamSource {
@required
@jsonName("na")
name: String
@required
@jsonName("de")
description: String
@required
@jsonName("nbm")
nbMembers: Integer
}

union Source {
forum: ForumSource
game: GameSource
study: StudySource
team: TeamSource
}
Loading
Loading