gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchl33-thinecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mrel33-thin/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

  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre
  • 6dea1c60Merge branch 'r35-day72' into mainTickets
  • 7bcfdc22|||PR drop worker edits to conductor recordsmre
  • 2617b6ee|||PR dialogs: host flag cleared on close, dialog gate (tickets#40)mre
  • 6e701371|||PR record partial day72 dialog validationmre
  • b9fb9a91|||PR bind ticket dialog visibility to member flagsmre
  • 0788e65f|||PR re-vendor Hybriel day72mre
  • e2a6bdcfMerge branch 'records-t35' into mainTickets
  • d8d54df1|||PR records: R35 day72 + #40mre
  • 8a7f475aMerge branch 'records-t33' into mainTickets
  • e685d0c2|||PR records: PROCEDURES merge callmre
  • b42aff2b|||PR records: GO 2026-11-23, workers L33 O34, PROCEDURES.mdmre
  • ed091d44Merge branch 'records' into mainTickets
  • 180c0cdb|||PR records: ticket move live (M32), hybriel#439mre
  • 497cae7bMerge branch 'm32-move' into mainTickets
  • 772e0696|||PR Allow project admins to move tickets between their projectsmre
  • be92a560Merge branch 'records' into mainTickets
  • 0daf2ea8|||PR records: PR-only workflow, #50 donemre
  • 0185d0b6Log PR 1 deploymre
  • f5bf16e2Mission 031: deploy PR 1mre