mirror of
https://github.com/thilo-behnke/wasm-pong.git
synced 2026-07-13 03:29:20 +00:00
problem: rskafka only fetches one record per topic
This commit is contained in:
@@ -10,10 +10,19 @@
|
||||
let state: GameState;
|
||||
$: state = $gameStateEvents;
|
||||
|
||||
let lastTick;
|
||||
|
||||
$: if (networkTickEvents && $networkTickEvents.hasNext) {
|
||||
const tick = networkTickEvents.next();
|
||||
if (tick != null) {
|
||||
gameField.update(tick.objects, state);
|
||||
console.warn(`Received tick: ${tick.tick}`)
|
||||
if (lastTick && lastTick.tick >= tick.tick) {
|
||||
console.error(`???? DUPLICATED TICK: ${JSON.stringify(tick)} (vs ${lastTick.tick}) ????`)
|
||||
} else {
|
||||
console.warn(`!!!! Valid tick: ${JSON.stringify(tick)} !!!!`)
|
||||
gameField.update(tick.objects, state);
|
||||
lastTick = tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export type InputEventPayload = {
|
||||
export type TickEventPayload = {
|
||||
session_id: string,
|
||||
objects: GameObject[],
|
||||
ts: number
|
||||
tick: number
|
||||
}
|
||||
|
||||
export type StatusEventPayload = {
|
||||
|
||||
@@ -150,7 +150,7 @@ impl KafkaEventReaderImpl {
|
||||
async fn consume(&mut self) -> Result<Vec<EventWrapper>, String> {
|
||||
debug!("kafka consumer called to consume messages for {:?} / {:?}", self.topic, self.partition);
|
||||
// TODO: Only 1 message?
|
||||
let next_res = tokio::time::timeout(Duration::from_millis(1), self.consumer.next()).await;
|
||||
let next_res = tokio::time::timeout(Duration::from_millis(3), self.consumer.next()).await;
|
||||
if let Err(e) = next_res {
|
||||
info!("No record received in time after {}, timeout for {} / {}.", e, self.topic, self.partition);
|
||||
return Ok(vec![]);
|
||||
|
||||
Reference in New Issue
Block a user