Skip to content

feat(access): add categories permissions and fix subscribe deadlocks - #197

Merged
parfeon merged 9 commits into
masterfrom
docs/CLEN-3779-CLEN-3758-CLEN-3339-readme-categories-abba
Oct 22, 2026
Merged

parfeon merged 9 commits into
masterfrom
docs/CLEN-3779-CLEN-3758-CLEN-3339-readme-categories-abba

Conversation

@parfeon

@parfeon parfeon commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

feat(access): add categories permissions to grant token

Add ChannelsCategoryPermission and UuidsCategoryPermission, the categories option for
grant_token, and parsing of category permissions in parse_token. Parsed token resources and
patterns are optional now.

feat(access): make Permission Send and Sync

Allow Permission implementations to be shared across threads.

Closes #188

fix(subscribe): fix DataStream and dispatcher deadlocks

Fix DataStream deadlock between push_data and poll_next which took queue and waker locks
in opposite order, and EventDispatcher deadlock between stream creation and invalidate.

refactor(client): remove redundant format! references

Remove redundant references in format! arguments of PubNubClientInstance, access and presence
request builders.

refactor(publish): add custom message type

Replace r#type with custom_message_type publish setter sent as custom_message_type query param.
Received Message exposes the same field, and examples and docs use the new name.

Closes #190

refactor(subscribe): skip unknown and malformed entries

Unknown e values and malformed envelopes are skipped instead of failing the whole subscribe
response. Payload is picked by event type first, then by -pnpres channel suffix.

build(cargo): update manifest and dev dependencies

Add keywords, enable access feature by default, update wiremock and cucumber, and register
the integration test target.

docs(readme): update PubNub Rust SDK header

Update README.md PubNub Rust SDK header.

test(access): cover category grants and token parsing

Add unit and integration tests for categories-only grants, all permission kinds, token parsing and
malformed tokens.

test(subscribe): cover stream lock order and wake-ups

Add tests for DataStream and EventDispatcher lock ordering, listener wake-ups and delivery of
dispatched batches.

test(subscribe): cover envelope parsing rules

Cover type-first classification, presence channel suffix, unknown event types, malformed
entries and message action added and removed events.

Add `ChannelsCategoryPermission` and `UuidsCategoryPermission`, the `categories` option for
`grant_token`, and parsing of category permissions in `parse_token`. Parsed token `resources` and
`patterns` are optional now.

fix(subscribe): fix `DataStream` and dispatcher deadlocks

Fix `DataStream` deadlock between `push_data` and `poll_next` which took `queue` and `waker` locks
in opposite order, and `EventDispatcher` deadlock between stream creation and `invalidate`.

refactor(client): remove redundant `format!` references

Remove redundant references in `format!` arguments of `PubNubClientInstance`, access and presence
request builders.

build(cargo): update manifest and dev dependencies

Add `keywords`, enable `access` feature by default, update `wiremock` and `cucumber`, and register
the `integration` test target.

docs(readme): update PubNub Rust SDK header

Update `README.md` PubNub Rust SDK header.

test(access): cover category grants and token parsing

Add unit and integration tests for categories-only grants, all permission kinds, token parsing and
malformed tokens.

test(subscribe): cover stream lock order and wake-ups

Add tests for `DataStream` and `EventDispatcher` lock ordering, listener wake-ups and delivery of
dispatched batches.
@codacy-production

codacy-production Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 1 medium

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 98 complexity · 185 duplication

Metric Results
Complexity 98
Duplication 185

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Xavrax Xavrax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

Comment thread Cargo.toml Outdated
Comment thread src/dx/access/builders/grant_token.rs Outdated
Comment thread src/dx/access/payloads.rs Outdated
Comment thread src/dx/access/payloads.rs
Comment thread src/dx/parse_token.rs Outdated
Gate `data_stream`, request helpers and `blocking` import so narrow feature builds compile.

refactor(parse_token): decouple parse_token from access feature

Move permission bits to `permission_bits` in core utils.
`parse_token` builds without `access`. `access` re-exports the bits.

refactor: address issues reported by PR reviewer

docs(readme): standardize README to SDK template
Allow `Permission` implementations to be shared across threads.

refactor(publish): add custom message type

Replace `r#type` with `custom_message_type` publish setter sent as `custom_message_type` query param.
Received `Message` exposes the same field, and examples and docs use the new name.

refactor(subscribe): skip unknown and malformed entries

Unknown `e` values and malformed envelopes are skipped instead of failing the whole subscribe
response. Payload is picked by event type first, then by `-pnpres` channel suffix.

refactor(publish): remove `space_id` from publish

Publish has no `space_id` parameter, so builder setter, `space-id` query param and
`space_id` field on received messages are removed.

build(deps): move reqwest to 0.13 with rustls

Update reqwest in dependencies and dev-dependencies and switch to rustls TLS backend.

test(subscribe): cover envelope parsing rules

Cover type-first classification, presence channel suffix, unknown event types, malformed
entries and message action `added` and `removed` events.
@parfeon parfeon added priority: medium This PR should be reviewed after all high priority PRs. status: done This issue is considered resolved. type: feature This PR contains new feature. type: fix This PR contains fixes to existing features. type: refactor This PR contains refactored existing features. labels Oct 22, 2026

@Xavrax Xavrax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few findings, overall LGTM

Comment thread README.md Outdated
Comment thread src/dx/access/builders/grant_token.rs
Comment thread src/dx/access/builders/grant_token.rs
Comment thread src/dx/access/payloads.rs
Comment thread src/dx/parse_token.rs
Comment thread src/dx/subscribe/result.rs
Comment thread src/dx/subscribe/event_dispatcher.rs Outdated
Repeated category entries are combined with bitwise OR and logged as a warning, instead of
overwriting the previous value. Categories passed to `resources` or `patterns` are logged as
an error and omitted from the payload.
@parfeon

parfeon commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@pubnub-release-bot release

@parfeon
parfeon merged commit 492cdfe into master Oct 22, 2026
10 checks passed
@parfeon
parfeon deleted the docs/CLEN-3779-CLEN-3758-CLEN-3339-readme-categories-abba branch October 22, 2026 18:25
@pubnub-release-bot

Copy link
Copy Markdown

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium This PR should be reviewed after all high priority PRs. status: done This issue is considered resolved. type: feature This PR contains new feature. type: fix This PR contains fixes to existing features. type: refactor This PR contains refactored existing features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants