Skip to content

Commit

Permalink
fix canary for vlang 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani committed Nov 28, 2022
1 parent fafe437 commit 00aa73e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vlogql-canary.v
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ mut:
streams []Result
}

fn canary_logs(mut app App, canary_string string) ? {
fn canary_logs(mut app App, canary_string string)! {
query := '{canary="$canary_string"}'

socket := app.api.replace('http', 'ws')
mut ws := websocket.new_client(socket + '/loki/api/v1/tail?query=' + query) ?
mut ws := websocket.new_client(socket + '/loki/api/v1/tail?query=' + query) !

ws.on_open(fn (mut ws websocket.Client) ? {
ws.on_open(fn (mut ws websocket.Client)! {
println('---------- Tail Canary Logs')
})
ws.on_error(fn (mut ws websocket.Client, err string) ? {
ws.on_error(fn (mut ws websocket.Client, err string)! {
eprintln('---------- Tail error: $err')
})
ws.on_message_ref(fn (mut ws websocket.Client, msg &websocket.Message, mut app App) ? {
ws.on_message_ref(fn (mut ws websocket.Client, msg &websocket.Message, mut app App)! {
if msg.payload.len > 0 {
diff_ts := now(0).i64() - app.last_ts.i64()
app.diff_ts = diff_ts.str()
Expand Down Expand Up @@ -118,7 +118,7 @@ fn canary_logs(mut app App, canary_string string) ? {
}
}

fn canary_emitter(mut app App, canary_string string, timer int, count int) ? {
fn canary_emitter(mut app App, canary_string string, timer int, count int)! {
labels := '{"canary":"$canary_string","type":"canary"}'
timestamp := now(0)
mut log := 'ts=$timestamp count=$count type=canary tag=$canary_string delay=$app.diff_ts'
Expand Down

0 comments on commit 00aa73e

Please sign in to comment.