Skip to content

Conversation

tobilg
Copy link
Contributor

@tobilg tobilg commented Jul 27, 2025

This adds an endpoint implementation for Cloudflare Queues. it uses the Cloudflare go SDK to push messages to a queue when geofences are hit via the HOOK and SET commands.

Cloudflare setup

Create a queue

With wrangler installed, use:

wrangler queues create test-queue

Then, get the queue id:

wrangler queues info test-queue

This will output something like this:

Queue Name: test-queue
Queue ID: 94b00cd6b4eb4efcb2315ab99800de2c
Created On: 2025-07-27T12:33:35.009426Z
Last Modified: 2025-07-27T12:33:35.009426Z
Number of Producers: 0
Number of Consumers: 0

Get your Account ID

See the docs on how to find your Cloudflare account id.

Create an API Token

You need to create an API Token that has one of the Queues Write or Workers Scripts Write permissions.

Usage

Setup hook

SETHOOK warehouse cf-queue://<account_id>/<queue_id>?token=<api_token> NEARBY fleet FENCE POINT 33.5123 -112.2693 500

Set position within the geofence

SET fleet truck1 POINT 33.5123 -112.2693

Set position outside the geofence

SET fleet truck1 POINT 33.5123 -115.2693

Resulting messages in the queue

{"command":"set","group":"688630afd024782a4d023ad1","detect":"enter","hook":"warehouse","key":"fleet","time":"2025-07-27T15:59:11.275075+02:00","id":"truck1","object":{"type":"Point","coordinates":[-112.2693,33.5123]}}
{"command":"set","group":"688630afd024782a4d023ad1","detect":"inside","hook":"warehouse","key":"fleet","time":"2025-07-27T15:59:11.275075+02:00","id":"truck1","object":{"type":"Point","coordinates":[-112.2693,33.5123]}}
{"command":"set","group":"688630afd024782a4d023ad1","detect":"exit","hook":"warehouse","key":"fleet","time":"2025-07-27T16:00:00.6083+02:00","id":"truck1","object":{"type":"Point","coordinates":[-115.2693,33.5123]}}
{"command":"set","group":"688630afd024782a4d023ad1","detect":"outside","hook":"warehouse","key":"fleet","time":"2025-07-27T16:00:00.6083+02:00","id":"truck1","object":{"type":"Point","coordinates":[-115.2693,33.5123]}}

@tidwall tidwall merged commit 35bde95 into tidwall:master Aug 1, 2025
1 check passed
@tobilg
Copy link
Contributor Author

tobilg commented Aug 3, 2025

Thanks for merging the PR!

@tidwall
Copy link
Owner

tidwall commented Aug 3, 2025

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants