gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb487b05ab487b05aRecord verified direct push protocol handoffmreb487b05a/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

  • b487b05aRecord verified direct push protocol handoffmre
  • 74e34cc3Verify encrypted push secrets and direct push retry semanticsmre
  • a1ac5cd0Push subscription notices directly to signed HyperConductor chat endpointsmre
  • d662ad27Remove superseded waker service for direct chat push protocolmre
  • ff2e8701Finalize subscription build verification and handoff reportmre
  • 54bc5fe1Harden delta relevance, overflow caps and retry verificationmre
  • 8d8e2053Document subscription contract and exercise delta deliverymre
  • fd23726aAdd subscription delta API and signed wake bridgemre
  • c5d28fb5Tickets conductor: S51 startedmre
  • fd6ca1e6Tickets conductor: brief 027 waker design, push-test projectmre
  • e448e656Tickets conductor: STATUS #51mre
  • 1c10857bTickets conductor: P51 eval, brief 027mre
  • e725969dTickets conductor: #51 directionmre
  • 1b5c63ddTickets conductor: P51 startedmre
  • 9f13fbdaTickets conductor: brief 026 prioritymre
  • acc477d9Tickets conductor: brief 026 + Vinzenz recommendationsmre
  • 9233a734Tickets conductor: brief 026 completemre
  • 5da589fdTickets conductor: brief 026 + Gitoria's answermre
  • a3cd5329Tickets conductor: tickets#51 opened, brief 026 draftmre
  • 6f6e5797Tickets conductor: STATUS wordingmre