Skip to content

Commit

Permalink
keep endpoint urls out of lower level code
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Sep 24, 2024
1 parent a175574 commit 24adaa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/main/scala/Controller.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ final class Controller(
) { Deps(emit, req, services) },
header,
credits = 100,
interval = 20.seconds
interval = 20.seconds,
alwaysFlush = true
)
case _ => notFound

Expand Down Expand Up @@ -302,14 +303,15 @@ object Controller:
val rateLimit: RateLimit,
val header: RequestHeader,
val emitCounter: kamon.metric.Counter,
val name: String
val alwaysFlush: Boolean
)
def endpoint(
name: String,
behavior: ClientEmit => ClientBehavior,
header: RequestHeader,
credits: Int,
interval: FiniteDuration
interval: FiniteDuration,
alwaysFlush: Boolean = false
): ResponseSync =
Monitor.connection.open(name)
Right:
Expand All @@ -322,7 +324,7 @@ object Controller:
),
header,
Monitor.clientInCounter(name),
name
alwaysFlush
)

type ResponseSync = Either[HttpResponseStatus, Endpoint]
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/netty/ActorChannelConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final private class ActorChannelConnector(clients: ActorRef[Clients.Control], lo
val clientPromise = Promise[Client]()
channel.attr(key.client).set(clientPromise.future)
val channelEmit: ClientEmit =
emitToChannel(channel, withFlush = endpoint.name == "round/play")
emitToChannel(channel, withFlush = endpoint.alwaysFlush)
val monitoredEmit: ClientEmit = (msg: ipc.ClientIn) =>
endpoint.emitCounter.increment()
channelEmit(msg)
Expand Down

0 comments on commit 24adaa7

Please sign in to comment.