gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf5bf16e2f5bf16e2Mission 031: deploy PR 1mref5bf16e2/tests/events-client.hl

1.2 KB

  1. // tests/events-client.hl — a PROGRAM subscribing to GET /api/events with hl:fetch's stream mode (ticket #26): prints
  2. // one line `EVENT <json>` per event and stops after EVENTS_MAX of them. tests/events.mjs runs it; it is also the
  3. // smallest example of a Hybriel subscriber.
  4. // EVENTS_URL=http://127.0.0.1:8790/api/events?project=alpha EVENTS_TOKEN=tkt_… EVENTS_MAX=2 ./bin/hybriel tests/events-client.hl
  5. import { fetch, fetchAbort } from 'hl:fetch'
  6. import { env } from 'hl:proc'
  7. url = env('EVENTS_URL')
  8. max = env('EVENTS_MAX') != null ? toNumber(env('EVENTS_MAX')) : 1
  9. let seen = 0
  10. let rest = ''
  11. p = fetch(url, { headers = { 'Authorization' = 'Bearer ' + env('EVENTS_TOKEN') } stream = true tag = 'events' })
  12. console.log('OPEN')
  13. on p.chunk({ chunk }) {
  14. rest = rest + chunk
  15. let at = rest.indexOf('data: ')
  16. while (seen < max && at >= 0 && rest.indexOf(newline, at) > at) {
  17. end = rest.indexOf(newline, at)
  18. console.log('EVENT ' + rest.slice(at + 6, end))
  19. seen = seen + 1
  20. rest = rest.slice(end + 1)
  21. at = rest.indexOf('data: ')
  22. }
  23. if (seen >= max) { fetchAbort('events') }
  24. }
  25. on p.done({ status }) { console.log('DONE ' + status) }
  26. // the language has no escapes: a newline is written as itself
  27. static newline = "
  28. "

Branches

Latest commits

  • f5bf16e2Mission 031: deploy PR 1mre
  • c69cd5f3Merge branch 'pr-flow' into mainTickets
  • cc56798cLog gitoria PR-only requestmre
  • d876d0b2|||PR README: changes land as PRsmre
  • fd83ac1fconductor: caramboleyo is the user, not owner/creatorApollo
  • 3b858c91Log backup hard-link fixmre
  • 7f6b37a0deploy.sh backup: tar --hard-dereference (hard links broke mpackdb sidecars on restore)mre
  • e93711d9Log E30 livemre
  • 59c02e4dMerge e30: preserve edited state note labels in Markdownmre
  • 30970796Log E30 deploy GOmre
  • 7c8e6d83Limit edited state note fix to Markdown renderingmre
  • 910536d0Log E30 reviewmre
  • 36984386Preserve state transitions when their notes are editedmre
  • d75cb946Log E30 startmre
  • 0bf3fefaMission 030: edited state note labelmre
  • 691565c6Log neutral-ticket rule checkmre
  • bc3bdecerecords: day38b live, #94 purgedmre
  • f6c5aa0dMerge main (records)mre
  • e23d42acconnect gate: wait for hydration before clicking Disconnectmre
  • a5d45d00records: D38 cause, GOmre