Skip to content

Commit 22ed31a

Browse files
authored
Fix handling empty messages (#48)
* feat: add flag to control rate limit * fix: handling empty messages
1 parent e688dd4 commit 22ed31a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Diff for: examples/manifest.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ data:
205205
[[tiers]]
206206
name = "0"
207207
[[tiers.rates]]
208-
interval = "1s"
209-
limit = 10
208+
interval = "1m"
209+
limit = 1
210210
211211
[[tiers]]
212212
name = "1"
@@ -247,6 +247,8 @@ spec:
247247
value: "0.0.0.0:9187"
248248
- name: OGMIOS_PORT
249249
value: "80"
250+
- name: OGMIOS_DNS
251+
value: "prj-mainnet-test.svc.cluster.local"
250252
- name: SSL_CRT_PATH
251253
value: "/ogmios-proxy/localhost.crt"
252254
- name: SSL_KEY_PATH

Diff for: proxy/src/proxy.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,16 @@ async fn handle_websocket(
196196
state.metrics.inc_ws_total_connection(&proxy_req);
197197

198198
let client_in = async {
199-
loop {
200-
let result = client_incoming.try_next().await;
199+
while let Some(result) = client_incoming.next().await {
201200
match result {
202201
Ok(data) => {
203-
if let Some(data) = data {
204-
limiter(state.clone(), proxy_req.consumer.as_ref().unwrap())
205-
.await;
206-
if let Err(err) = instance_outgoing.send(data).await {
207-
error!(
208-
error = err.to_string(),
209-
"fail to send data to instance"
210-
);
211-
break;
212-
}
202+
limiter(state.clone(), proxy_req.consumer.as_ref().unwrap()).await;
203+
if let Err(err) = instance_outgoing.send(data).await {
204+
error!(
205+
error = err.to_string(),
206+
"fail to send data to instance"
207+
);
208+
break;
213209
}
214210
}
215211
Err(err) => {

0 commit comments

Comments
 (0)