Reference implementations

The websemaphore examples repo on GitHub provides a starting point for both http and websockets -based flows. Check it out:

Full l

Basic job operations

Test NamePurposeWebSocketsHTTP
_01_basicBasic happy path test: acquire, process, and release a lock.01-websockets-basic.ts01-http-basic.ts
_02_timeoutTest job timeout behavior.02-websockets-timeout.ts02-http-timeout.ts
_03_rescheduleBasic reschedule test: timeout a job, reschedule it, and verify it retains its properties.03-websockets-reschedule-basic.ts03-http-reschedule-basic.ts
_04_reschedule_orderVerify that rescheduled jobs are processed before newer jobs.04-websockets-reschedule-order.ts04-http-reschedule-order.ts
_05_requeueRequeue a timed-out job and verify it retains its payload but gets a new CRN.05-websockets-requeue.ts05-http-requeue.ts
_06_cancelCancel a job during processing and verify it transitions to the archived state.06-websockets-cancel.ts06-http-cancel.ts
_07_deleteDelete a timed-out job and verify it transitions to the archived state.07-websockets-delete.ts07-http-delete-test.ts

Mapping, failover and advanced routing

Test NamePurposeFile Name
_10_mapping_basicTest dynamic mapping10-websockets-mapping-basic.ts
_11_mapping_change_transportChange transport in mapping from WebSockets to HTTP.11-mapping-change-transport.ts
_21_transport_http_fallbackFall back to HTTP when WebSocket connection drops.21-transport-http-fallback.ts
_22_transport_websemaphore_fallbackFallback to another WebSemaphore when all other options fail.22-transport-websemaphore-fallback.ts

Concurrency control and channels

Test NamePurposeFile Name
_33_channel_distinctionVerify that jobs on different channels are processed independently.33-channel-distinction.ts
_34_channel_suspensionVerify that deactivating one channel does not affect the functionality of another channel.34-channel-suspension.ts
_35_concurrency_controlVerify that the semaphore respects maxValue when processing multiple jobs concurrently.35-concurrency-control.ts