-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better naming for client and introduce noop client
- Loading branch information
1 parent
4985a41
commit 58d53ad
Showing
6 changed files
with
88 additions
and
53 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,30 @@ | ||
package lila.search | ||
package client | ||
|
||
import lila.search.spec.* | ||
import scala.concurrent.Future | ||
|
||
object NoopSearchClient extends SearchClient: | ||
|
||
override def refresh(index: Index): Future[Unit] = Future.successful(()) | ||
|
||
override def storeBulkTeam(sources: List[TeamSourceWithId]): Future[Unit] = Future.successful(()) | ||
|
||
override def deleteByIds(index: Index, ids: List[String]): Future[Unit] = Future.successful(()) | ||
|
||
override def storeBulkForum(sources: List[ForumSourceWithId]): Future[Unit] = Future.successful(()) | ||
|
||
override def deleteById(index: Index, id: String): Future[Unit] = Future.successful(()) | ||
|
||
override def search(query: Query, from: Int, size: Int): Future[SearchResponse] = | ||
Future.successful(SearchResponse(Nil)) | ||
|
||
override def store(id: String, source: Source): Future[Unit] = Future.successful(()) | ||
|
||
override def storeBulkGame(sources: List[GameSourceWithId]): Future[Unit] = Future.successful(()) | ||
|
||
override def storeBulkStudy(sources: List[StudySourceWithId]): Future[Unit] = Future.successful(()) | ||
|
||
override def count(query: Query): Future[CountResponse] = Future.successful(CountResponse(0)) | ||
|
||
override def mapping(index: Index): Future[Unit] = Future.successful(()) |
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,45 @@ | ||
package lila.search | ||
package client | ||
|
||
import lila.search.spec.* | ||
import play.api.libs.ws.StandaloneWSClient | ||
import scala.concurrent.ExecutionContext | ||
import scala.concurrent.Future | ||
import scala.annotation.targetName | ||
|
||
trait SearchClient extends SearchService[Future] { client => | ||
@targetName("storeBulkTeamWithPair") | ||
def storeBulkTeam(sources: List[(String, TeamSource)]): Future[Unit] = | ||
client.storeBulkTeam(sources.map(TeamSourceWithId.apply.tupled)) | ||
|
||
@targetName("storeBulkStudyWithPair") | ||
def storeBulkStudy(sources: List[(String, StudySource)]): Future[Unit] = | ||
client.storeBulkStudy(sources.map(StudySourceWithId.apply.tupled)) | ||
|
||
@targetName("storeBulkGameWithPair") | ||
def storeBulkGame(sources: List[(String, GameSource)]): Future[Unit] = | ||
client.storeBulkGame(sources.map(GameSourceWithId.apply.tupled)) | ||
|
||
@targetName("storeBulkForumWithPair") | ||
def storeBulkForum(sources: List[(String, ForumSource)]): Future[Unit] = | ||
client.storeBulkForum(sources.map(ForumSourceWithId.apply.tupled)) | ||
|
||
def storeForum(id: String, source: ForumSource): Future[Unit] = | ||
client.store(id, Source.forum(source)) | ||
|
||
def storeGame(id: String, source: GameSource): Future[Unit] = | ||
client.store(id, Source.game(source)) | ||
|
||
def storeStudy(id: String, source: StudySource): Future[Unit] = | ||
client.store(id, Source.study(source)) | ||
|
||
def storeTeam(id: String, source: TeamSource): Future[Unit] = | ||
client.store(id, Source.team(source)) | ||
} | ||
|
||
object SearchClient: | ||
|
||
def noop: SearchClient = NoopSearchClient | ||
|
||
def play(client: StandaloneWSClient, baseUrl: String)(using ec: ExecutionContext): SearchClient = | ||
PlaySearchClient(client, baseUrl) |
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