fix(users/Profpatsch/whatcd-resolver): fix transmission session

The logic around transmission session handling was f*cked, this fixes
that.

We use an IORef instead of an MVar, since we want to unconditionally
write the new value. Even if multiple requests race, I *hope* that
transmission returns the same session id, otherwise we might get a
request loop. But it should be fine. (The semantics is not nicely
documented in the RPC docs.)

Additionally, log the session ids in the requests.

Change-Id: Id7d33f8cb74cb349e502331cad5eb5abe8a624cd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11673
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2024-05-15 11:49:54 +02:00 committed by clbot
parent 3b8b47baba
commit 2ac89bb480
3 changed files with 24 additions and 11 deletions

View file

@ -27,7 +27,7 @@ data Context = Context
tracer :: Otel.Tracer,
pgFormat :: PgFormatPool,
pgConnPool :: Pool Postgres.Connection,
transmissionSessionId :: MVar ByteString
transmissionSessionId :: IORef (Maybe ByteString)
}
newtype AppT m a = AppT {unAppT :: ReaderT Context m a}