tickets
All repositories: gitoria
1.2 KB
// tests/events-client.hl — a PROGRAM subscribing to GET /api/events with hl:fetch's stream mode (ticket #26): prints// one line `EVENT <json>` per event and stops after EVENTS_MAX of them. tests/events.mjs runs it; it is also the// smallest example of a Hybriel subscriber.// EVENTS_URL=http://127.0.0.1:8790/api/events?project=alpha EVENTS_TOKEN=tkt_… EVENTS_MAX=2 ./bin/hybriel tests/events-client.hlimport { fetch, fetchAbort } from 'hl:fetch'import { env } from 'hl:proc'url = env('EVENTS_URL')max = env('EVENTS_MAX') != null ? toNumber(env('EVENTS_MAX')) : 1let seen = 0let rest = ''p = fetch(url, { headers = { 'Authorization' = 'Bearer ' + env('EVENTS_TOKEN') } stream = true tag = 'events' })console.log('OPEN')on p.chunk({ chunk }) {rest = rest + chunklet at = rest.indexOf('data: ')while (seen < max && at >= 0 && rest.indexOf(newline, at) > at) {end = rest.indexOf(newline, at)console.log('EVENT ' + rest.slice(at + 6, end))seen = seen + 1rest = rest.slice(end + 1)at = rest.indexOf('data: ')}if (seen >= max) { fetchAbort('events') }}on p.done({ status }) { console.log('DONE ' + status) }// the language has no escapes: a newline is written as itselfstatic newline = ""
Branches
Latest commits
- 6f6e5797Tickets conductor: STATUS wordingmre
- 957de51fTickets conductor: T36 live, #36 review, #50 donemre
- bc2fde32Merge branch 'main' into t36-stylemre
- b7ca093atests: wait for the new row and normalize editor marker spacesmre
- 41da3525Tickets conductor: flake cause, T36 deploy stepmre
- 64c477e6Tickets conductor: deploy waits for Arachnemre
- 467d7286Tickets conductor: T36 done, deploy questionmre
- fed5ca81ticket_list: remove repeated selected-state coloursmre
- 8542fc8aTickets conductor: T36 proof reviewedmre
- 35980936inbox: preserve desktop columns after list styles were scopedmre
- 2a5b8b91Tickets conductor: T36 cap stop, resumed for proofmre
- c077a5cbstyles: format Style with nested language rulesmre
- ccdde2beticket: format Style with nested language rulesmre
- d083535bticket_list: nest Style rules and bare media queriesmre
- c24608ebmarkdown: format Style with nested language rulesmre
- de964b3bsettings: format Style with nested language rulesmre
- 03c1de05new_project: format Style with nested language rulesmre
- bd76cfa6connect: format Style with nested language rulesmre
- 01fad593inbox: format Style with nested language rulesmre
- 79dc9392you: format Style with nested language rulesmre