Skip to content

feat: add async/await support for Config and DefaultModel#54

Open
zamderax wants to merge 3 commits intoapache:masterfrom
wendylabsinc:feat/management-rbac-async-await
Open

feat: add async/await support for Config and DefaultModel#54
zamderax wants to merge 3 commits intoapache:masterfrom
wendylabsinc:feat/management-rbac-async-await

Conversation

@zamderax
Copy link
Copy Markdown
Contributor

@zamderax zamderax commented Oct 16, 2025

Summary

Add async/await overloads for Config and DefaultModel static factory methods, continuing the Swift 6 concurrency migration started in PR #53.

Changes

Config+AsyncAwait.swift

  • Added async/await overloads for from(file:fileIo:on:) static factory method
  • Added async/await overloads for from(text:on:) static factory method
  • Methods bridge existing EventLoopFuture-based APIs using continuation pattern
  • Availability-gated with @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)

DefaultModel+AsyncAwait.swift

  • Added async/await overloads for from(file:fileIo:on:) static factory method
  • Added async/await overloads for from(text:on:) static factory method
  • Methods bridge existing EventLoopFuture-based APIs using continuation pattern
  • Availability-gated with @available(macOS 10.15, iOS 13.0, tvOS 13.0, *)

Implementation Pattern

Test Plan

Related PRs

zamderax and others added 3 commits October 16, 2025 10:20
- Add async/await overloads for named policy and grouping policy methods
- Add async/await overloads for RBAC API methods (permissions, roles, users)
- Create comprehensive test suites for ManagementApi and RBACApi async/await methods
- Properly manage EventLoopGroup lifecycle in tests with defer cleanup
- All 13 tests passing (6 Management + 7 RBAC)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename Sources/Casbin/APi/RBACApi.swift to RBACAPI.swift
- Rename Tests/CasbinTests/RbacApiTests.swift to RBACAPITests.swift
- Update struct name from RbacApiTests to RBACAPITests
- All 15 tests passing (2 RBAC API + 6 Management + 7 RBAC Async)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Config+AsyncAwait.swift with async/await overloads for static factory methods
- Add DefaultModel+AsyncAwait.swift with async/await overloads for static factory methods
- Both follow the same pattern as PR apache#53 with @available annotations and continuation-based bridging
- Methods bridge existing EventLoopFuture-based APIs to async/await

Note: Tests have a pre-existing hang issue on this branch unrelated to these changes.
The code compiles successfully and follows the established async/await patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zamderax zamderax marked this pull request as draft October 16, 2025 09:39
@hsluoyz
Copy link
Copy Markdown
Member

hsluoyz commented Oct 19, 2025

@zamderax is this ready?

@zamderax
Copy link
Copy Markdown
Contributor Author

zamderax commented Oct 19, 2025 via email

@hsluoyz hsluoyz marked this pull request as ready for review December 19, 2025 18:29
@hsluoyz hsluoyz requested a review from Copilot January 1, 2026 02:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds async/await support for Config and DefaultModel static factory methods, continuing the Swift 6 concurrency migration. The PR also includes new RBAC API implementations and additional async test coverage.

  • Added async/await overloads for Config and DefaultModel static factory methods using continuation bridging
  • Added async/await wrapper methods for Enforcer RBAC and Management APIs
  • Introduced RBACAPI.swift with EventLoopFuture-based RBAC helper methods

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Sources/Casbin/Config+AsyncAwait.swift New file adding async/await overloads for Config.from(file:) and Config.from(text:) methods with proper availability gating
Sources/Casbin/Model/DefaultModel+AsyncAwait.swift New file adding async/await overloads for DefaultModel.from(file:) and DefaultModel.from(text:) methods with proper availability gating
Sources/Casbin/Enforcer+AsyncAwait.swift Extended with async/await wrappers for named policy, named grouping policy, and RBAC API methods
Sources/Casbin/APi/RBACAPI.swift New file implementing RBAC convenience methods as extensions on CoreApi protocol
Tests/CasbinTests/RBACAPITests.swift Fixed struct name from RbacApiTests to RBACAPITests for consistency
Tests/CasbinTests/EnforcerRBACAsyncTests.swift New test file providing comprehensive coverage for async RBAC APIs
Tests/CasbinTests/EnforcerManagementAsyncTests.swift New test file providing comprehensive coverage for async management APIs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants