Skip to content

Commit

Permalink
feat: remove Adapter requirement in ContextAdapter (#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Apr 7, 2024
1 parent ef82104 commit 4ab2e54
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions persist/adapter_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (

// ContextAdapter provides a context-aware interface for Casbin adapters.
type ContextAdapter interface {
Adapter

// LoadPolicyCtx loads all policy rules from the storage with context.
LoadPolicyCtx(ctx context.Context, model model.Model) error
// SavePolicyCtx saves all policy rules to the storage with context.
Expand Down

1 comment on commit 4ab2e54

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 4ab2e54 Previous: ef82104 Ratio
BenchmarkCachedRaw 17.56 ns/op 0 B/op 0 allocs/op 17.53 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkCachedRaw - ns/op 17.56 ns/op 17.53 ns/op 1.00
BenchmarkCachedRaw - B/op 0 B/op 0 B/op 1
BenchmarkCachedRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkCachedBasicModel 167.3 ns/op 104 B/op 4 allocs/op 169 ns/op 104 B/op 4 allocs/op 0.99
BenchmarkCachedBasicModel - ns/op 167.3 ns/op 169 ns/op 0.99
BenchmarkCachedBasicModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedBasicModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModel 165.9 ns/op 104 B/op 4 allocs/op 169 ns/op 104 B/op 4 allocs/op 0.98
BenchmarkCachedRBACModel - ns/op 165.9 ns/op 169 ns/op 0.98
BenchmarkCachedRBACModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelSmall 179.7 ns/op 104 B/op 4 allocs/op 179.7 ns/op 104 B/op 4 allocs/op 1
BenchmarkCachedRBACModelSmall - ns/op 179.7 ns/op 179.7 ns/op 1
BenchmarkCachedRBACModelSmall - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelSmall - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelMedium 182.8 ns/op 104 B/op 4 allocs/op 186 ns/op 104 B/op 4 allocs/op 0.98
BenchmarkCachedRBACModelMedium - ns/op 182.8 ns/op 186 ns/op 0.98
BenchmarkCachedRBACModelMedium - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelMedium - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelLarge 164.2 ns/op 96 B/op 3 allocs/op 166.1 ns/op 96 B/op 3 allocs/op 0.99
BenchmarkCachedRBACModelLarge - ns/op 164.2 ns/op 166.1 ns/op 0.99
BenchmarkCachedRBACModelLarge - B/op 96 B/op 96 B/op 1
BenchmarkCachedRBACModelLarge - allocs/op 3 allocs/op 3 allocs/op 1
BenchmarkCachedRBACModelWithResourceRoles 167.1 ns/op 104 B/op 4 allocs/op 171.6 ns/op 104 B/op 4 allocs/op 0.97
BenchmarkCachedRBACModelWithResourceRoles - ns/op 167.1 ns/op 171.6 ns/op 0.97
BenchmarkCachedRBACModelWithResourceRoles - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithResourceRoles - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDomains 179.8 ns/op 120 B/op 4 allocs/op 179.1 ns/op 120 B/op 4 allocs/op 1.00
BenchmarkCachedRBACModelWithDomains - ns/op 179.8 ns/op 179.1 ns/op 1.00
BenchmarkCachedRBACModelWithDomains - B/op 120 B/op 120 B/op 1
BenchmarkCachedRBACModelWithDomains - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedABACModel 2747 ns/op 1538 B/op 18 allocs/op 2780 ns/op 1537 B/op 18 allocs/op 0.99
BenchmarkCachedABACModel - ns/op 2747 ns/op 2780 ns/op 0.99
BenchmarkCachedABACModel - B/op 1538 B/op 1537 B/op 1.00
BenchmarkCachedABACModel - allocs/op 18 allocs/op 18 allocs/op 1
BenchmarkCachedKeyMatchModel 184.3 ns/op 152 B/op 4 allocs/op 188.3 ns/op 152 B/op 4 allocs/op 0.98
BenchmarkCachedKeyMatchModel - ns/op 184.3 ns/op 188.3 ns/op 0.98
BenchmarkCachedKeyMatchModel - B/op 152 B/op 152 B/op 1
BenchmarkCachedKeyMatchModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDeny 168.9 ns/op 104 B/op 4 allocs/op 170.2 ns/op 104 B/op 4 allocs/op 0.99
BenchmarkCachedRBACModelWithDeny - ns/op 168.9 ns/op 170.2 ns/op 0.99
BenchmarkCachedRBACModelWithDeny - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithDeny - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedPriorityModel 167.2 ns/op 104 B/op 4 allocs/op 168.5 ns/op 104 B/op 4 allocs/op 0.99
BenchmarkCachedPriorityModel - ns/op 167.2 ns/op 168.5 ns/op 0.99
BenchmarkCachedPriorityModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedPriorityModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedWithEnforceContext 298.8 ns/op 240 B/op 5 allocs/op 302.4 ns/op 240 B/op 5 allocs/op 0.99
BenchmarkCachedWithEnforceContext - ns/op 298.8 ns/op 302.4 ns/op 0.99
BenchmarkCachedWithEnforceContext - B/op 240 B/op 240 B/op 1
BenchmarkCachedWithEnforceContext - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkCachedRBACModelMediumParallel 173.5 ns/op 106 B/op 4 allocs/op 172.3 ns/op 106 B/op 4 allocs/op 1.01
BenchmarkCachedRBACModelMediumParallel - ns/op 173.5 ns/op 172.3 ns/op 1.01
BenchmarkCachedRBACModelMediumParallel - B/op 106 B/op 106 B/op 1
BenchmarkCachedRBACModelMediumParallel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkHasPolicySmall 450.3 ns/op 150 B/op 6 allocs/op 469.4 ns/op 150 B/op 6 allocs/op 0.96
BenchmarkHasPolicySmall - ns/op 450.3 ns/op 469.4 ns/op 0.96
BenchmarkHasPolicySmall - B/op 150 B/op 150 B/op 1
BenchmarkHasPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyMedium 482.9 ns/op 157 B/op 6 allocs/op 503.6 ns/op 157 B/op 6 allocs/op 0.96
BenchmarkHasPolicyMedium - ns/op 482.9 ns/op 503.6 ns/op 0.96
BenchmarkHasPolicyMedium - B/op 157 B/op 157 B/op 1
BenchmarkHasPolicyMedium - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyLarge 511.9 ns/op 165 B/op 7 allocs/op 527.1 ns/op 165 B/op 7 allocs/op 0.97
BenchmarkHasPolicyLarge - ns/op 511.9 ns/op 527.1 ns/op 0.97
BenchmarkHasPolicyLarge - B/op 165 B/op 165 B/op 1
BenchmarkHasPolicyLarge - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicySmall 485.1 ns/op 152 B/op 6 allocs/op 484.5 ns/op 152 B/op 6 allocs/op 1.00
BenchmarkAddPolicySmall - ns/op 485.1 ns/op 484.5 ns/op 1.00
BenchmarkAddPolicySmall - B/op 152 B/op 152 B/op 1
BenchmarkAddPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkAddPolicyMedium 600.3 ns/op 176 B/op 7 allocs/op 654.9 ns/op 178 B/op 7 allocs/op 0.92
BenchmarkAddPolicyMedium - ns/op 600.3 ns/op 654.9 ns/op 0.92
BenchmarkAddPolicyMedium - B/op 176 B/op 178 B/op 0.99
BenchmarkAddPolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicyLarge 1124 ns/op 470 B/op 9 allocs/op 1193 ns/op 470 B/op 9 allocs/op 0.94
BenchmarkAddPolicyLarge - ns/op 1124 ns/op 1193 ns/op 0.94
BenchmarkAddPolicyLarge - B/op 470 B/op 470 B/op 1
BenchmarkAddPolicyLarge - allocs/op 9 allocs/op 9 allocs/op 1
BenchmarkRemovePolicySmall 491.9 ns/op 166 B/op 7 allocs/op 500.6 ns/op 166 B/op 7 allocs/op 0.98
BenchmarkRemovePolicySmall - ns/op 491.9 ns/op 500.6 ns/op 0.98
BenchmarkRemovePolicySmall - B/op 166 B/op 166 B/op 1
BenchmarkRemovePolicySmall - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyMedium 535.4 ns/op 176 B/op 7 allocs/op 548.9 ns/op 176 B/op 7 allocs/op 0.98
BenchmarkRemovePolicyMedium - ns/op 535.4 ns/op 548.9 ns/op 0.98
BenchmarkRemovePolicyMedium - B/op 176 B/op 176 B/op 1
BenchmarkRemovePolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyLarge 1335 ns/op 298 B/op 13 allocs/op 1267 ns/op 294 B/op 13 allocs/op 1.05
BenchmarkRemovePolicyLarge - ns/op 1335 ns/op 1267 ns/op 1.05
BenchmarkRemovePolicyLarge - B/op 298 B/op 294 B/op 1.01
BenchmarkRemovePolicyLarge - allocs/op 13 allocs/op 13 allocs/op 1
BenchmarkRaw 17.46 ns/op 0 B/op 0 allocs/op 17.44 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkRaw - ns/op 17.46 ns/op 17.44 ns/op 1.00
BenchmarkRaw - B/op 0 B/op 0 B/op 1
BenchmarkRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkBasicModel 3490 ns/op 1506 B/op 17 allocs/op 3590 ns/op 1506 B/op 17 allocs/op 0.97
BenchmarkBasicModel - ns/op 3490 ns/op 3590 ns/op 0.97
BenchmarkBasicModel - B/op 1506 B/op 1506 B/op 1
BenchmarkBasicModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkRBACModel 5237 ns/op 2056 B/op 35 allocs/op 5459 ns/op 2062 B/op 35 allocs/op 0.96
BenchmarkRBACModel - ns/op 5237 ns/op 5459 ns/op 0.96
BenchmarkRBACModel - B/op 2056 B/op 2062 B/op 1.00
BenchmarkRBACModel - allocs/op 35 allocs/op 35 allocs/op 1
BenchmarkRBACModelSizes/small 50716 ns/op 20161 B/op 480 allocs/op 50102 ns/op 20279 B/op 480 allocs/op 1.01
BenchmarkRBACModelSizes/small - ns/op 50716 ns/op 50102 ns/op 1.01
BenchmarkRBACModelSizes/small - B/op 20161 B/op 20279 B/op 0.99
BenchmarkRBACModelSizes/small - allocs/op 480 allocs/op 480 allocs/op 1
BenchmarkRBACModelSizes/medium 480581 ns/op 191332 B/op 4828 allocs/op 525344 ns/op 191762 B/op 4828 allocs/op 0.91
BenchmarkRBACModelSizes/medium - ns/op 480581 ns/op 525344 ns/op 0.91
BenchmarkRBACModelSizes/medium - B/op 191332 B/op 191762 B/op 1.00
BenchmarkRBACModelSizes/medium - allocs/op 4828 allocs/op 4828 allocs/op 1
BenchmarkRBACModelSizes/large 5170863 ns/op 1899738 B/op 48173 allocs/op 5737197 ns/op 1907166 B/op 48367 allocs/op 0.90
BenchmarkRBACModelSizes/large - ns/op 5170863 ns/op 5737197 ns/op 0.90
BenchmarkRBACModelSizes/large - B/op 1899738 B/op 1907166 B/op 1.00
BenchmarkRBACModelSizes/large - allocs/op 48173 allocs/op 48367 allocs/op 1.00
BenchmarkRBACModelSmall 59247 ns/op 20235 B/op 615 allocs/op 60599 ns/op 20199 B/op 615 allocs/op 0.98
BenchmarkRBACModelSmall - ns/op 59247 ns/op 60599 ns/op 0.98
BenchmarkRBACModelSmall - B/op 20235 B/op 20199 B/op 1.00
BenchmarkRBACModelSmall - allocs/op 615 allocs/op 615 allocs/op 1
BenchmarkRBACModelMedium 560536 ns/op 194226 B/op 6020 allocs/op 576550 ns/op 194097 B/op 6021 allocs/op 0.97
BenchmarkRBACModelMedium - ns/op 560536 ns/op 576550 ns/op 0.97
BenchmarkRBACModelMedium - B/op 194226 B/op 194097 B/op 1.00
BenchmarkRBACModelMedium - allocs/op 6020 allocs/op 6021 allocs/op 1.00
BenchmarkRBACModelLarge 6018989 ns/op 1940174 B/op 60589 allocs/op 6103947 ns/op 1942495 B/op 60679 allocs/op 0.99
BenchmarkRBACModelLarge - ns/op 6018989 ns/op 6103947 ns/op 0.99
BenchmarkRBACModelLarge - B/op 1940174 B/op 1942495 B/op 1.00
BenchmarkRBACModelLarge - allocs/op 60589 allocs/op 60679 allocs/op 1.00
BenchmarkRBACModelWithResourceRoles 5101 ns/op 2728 B/op 28 allocs/op 5183 ns/op 2732 B/op 28 allocs/op 0.98
BenchmarkRBACModelWithResourceRoles - ns/op 5101 ns/op 5183 ns/op 0.98
BenchmarkRBACModelWithResourceRoles - B/op 2728 B/op 2732 B/op 1.00
BenchmarkRBACModelWithResourceRoles - allocs/op 28 allocs/op 28 allocs/op 1
BenchmarkRBACModelWithDomains 4983 ns/op 1823 B/op 25 allocs/op 5058 ns/op 1824 B/op 25 allocs/op 0.99
BenchmarkRBACModelWithDomains - ns/op 4983 ns/op 5058 ns/op 0.99
BenchmarkRBACModelWithDomains - B/op 1823 B/op 1824 B/op 1.00
BenchmarkRBACModelWithDomains - allocs/op 25 allocs/op 25 allocs/op 1
BenchmarkABACModel 2669 ns/op 1531 B/op 17 allocs/op 2721 ns/op 1533 B/op 17 allocs/op 0.98
BenchmarkABACModel - ns/op 2669 ns/op 2721 ns/op 0.98
BenchmarkABACModel - B/op 1531 B/op 1533 B/op 1.00
BenchmarkABACModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkABACRuleModel 3830976 ns/op 1324785 B/op 40091 allocs/op 3878069 ns/op 1321837 B/op 40091 allocs/op 0.99
BenchmarkABACRuleModel - ns/op 3830976 ns/op 3878069 ns/op 0.99
BenchmarkABACRuleModel - B/op 1324785 B/op 1321837 B/op 1.00
BenchmarkABACRuleModel - allocs/op 40091 allocs/op 40091 allocs/op 1
BenchmarkKeyMatchModel 5836 ns/op 3061 B/op 37 allocs/op 5958 ns/op 3065 B/op 37 allocs/op 0.98
BenchmarkKeyMatchModel - ns/op 5836 ns/op 5958 ns/op 0.98
BenchmarkKeyMatchModel - B/op 3061 B/op 3065 B/op 1.00
BenchmarkKeyMatchModel - allocs/op 37 allocs/op 37 allocs/op 1
BenchmarkRBACModelWithDeny 6822 ns/op 2472 B/op 49 allocs/op 6805 ns/op 2474 B/op 49 allocs/op 1.00
BenchmarkRBACModelWithDeny - ns/op 6822 ns/op 6805 ns/op 1.00
BenchmarkRBACModelWithDeny - B/op 2472 B/op 2474 B/op 1.00
BenchmarkRBACModelWithDeny - allocs/op 49 allocs/op 49 allocs/op 1
BenchmarkPriorityModel 4084 ns/op 1758 B/op 22 allocs/op 4170 ns/op 1759 B/op 22 allocs/op 0.98
BenchmarkPriorityModel - ns/op 4084 ns/op 4170 ns/op 0.98
BenchmarkPriorityModel - B/op 1758 B/op 1759 B/op 1.00
BenchmarkPriorityModel - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkRBACModelWithDomainPatternLarge 22266 ns/op 16712 B/op 164 allocs/op 23572 ns/op 16716 B/op 164 allocs/op 0.94
BenchmarkRBACModelWithDomainPatternLarge - ns/op 22266 ns/op 23572 ns/op 0.94
BenchmarkRBACModelWithDomainPatternLarge - B/op 16712 B/op 16716 B/op 1.00
BenchmarkRBACModelWithDomainPatternLarge - allocs/op 164 allocs/op 164 allocs/op 1
BenchmarkRoleManagerSmall 67631 ns/op 11955 B/op 797 allocs/op 68652 ns/op 11955 B/op 797 allocs/op 0.99
BenchmarkRoleManagerSmall - ns/op 67631 ns/op 68652 ns/op 0.99
BenchmarkRoleManagerSmall - B/op 11955 B/op 11955 B/op 1
BenchmarkRoleManagerSmall - allocs/op 797 allocs/op 797 allocs/op 1
BenchmarkRoleManagerMedium 709327 ns/op 125914 B/op 8741 allocs/op 716566 ns/op 125915 B/op 8741 allocs/op 0.99
BenchmarkRoleManagerMedium - ns/op 709327 ns/op 716566 ns/op 0.99
BenchmarkRoleManagerMedium - B/op 125914 B/op 125915 B/op 1.00
BenchmarkRoleManagerMedium - allocs/op 8741 allocs/op 8741 allocs/op 1
BenchmarkRoleManagerLarge 7692067 ns/op 1349923 B/op 89741 allocs/op 8080128 ns/op 1349928 B/op 89741 allocs/op 0.95
BenchmarkRoleManagerLarge - ns/op 7692067 ns/op 8080128 ns/op 0.95
BenchmarkRoleManagerLarge - B/op 1349923 B/op 1349928 B/op 1.00
BenchmarkRoleManagerLarge - allocs/op 89741 allocs/op 89741 allocs/op 1
BenchmarkBuildRoleLinksWithPatternLarge 5807221874 ns/op 5331762592 B/op 60946274 allocs/op 6324793611 ns/op 5344128080 B/op 60948858 allocs/op 0.92
BenchmarkBuildRoleLinksWithPatternLarge - ns/op 5807221874 ns/op 6324793611 ns/op 0.92
BenchmarkBuildRoleLinksWithPatternLarge - B/op 5331762592 B/op 5344128080 B/op 1.00
BenchmarkBuildRoleLinksWithPatternLarge - allocs/op 60946274 allocs/op 60948858 allocs/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge 159208167 ns/op 141145875 B/op 1676413 allocs/op 177154752 ns/op 141689830 B/op 1676510 allocs/op 0.90
BenchmarkBuildRoleLinksWithDomainPatternLarge - ns/op 159208167 ns/op 177154752 ns/op 0.90
BenchmarkBuildRoleLinksWithDomainPatternLarge - B/op 141145875 B/op 141689830 B/op 1.00
BenchmarkBuildRoleLinksWithDomainPatternLarge - allocs/op 1676413 allocs/op 1676510 allocs/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge 5974960070 ns/op 5471246928 B/op 62557225 allocs/op 6814618958 ns/op 5486254440 B/op 62560314 allocs/op 0.88
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - ns/op 5974960070 ns/op 6814618958 ns/op 0.88
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - B/op 5471246928 B/op 5486254440 B/op 1.00
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - allocs/op 62557225 allocs/op 62560314 allocs/op 1.00
BenchmarkHasLinkWithPatternLarge 9905 ns/op 7591 B/op 111 allocs/op 10736 ns/op 7601 B/op 111 allocs/op 0.92
BenchmarkHasLinkWithPatternLarge - ns/op 9905 ns/op 10736 ns/op 0.92
BenchmarkHasLinkWithPatternLarge - B/op 7591 B/op 7601 B/op 1.00
BenchmarkHasLinkWithPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1
BenchmarkHasLinkWithDomainPatternLarge 468.6 ns/op 80 B/op 5 allocs/op 482.9 ns/op 80 B/op 5 allocs/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - ns/op 468.6 ns/op 482.9 ns/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - B/op 80 B/op 80 B/op 1
BenchmarkHasLinkWithDomainPatternLarge - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkHasLinkWithPatternAndDomainPatternLarge 9918 ns/op 7595 B/op 111 allocs/op 10506 ns/op 7604 B/op 111 allocs/op 0.94
BenchmarkHasLinkWithPatternAndDomainPatternLarge - ns/op 9918 ns/op 10506 ns/op 0.94
BenchmarkHasLinkWithPatternAndDomainPatternLarge - B/op 7595 B/op 7604 B/op 1.00
BenchmarkHasLinkWithPatternAndDomainPatternLarge - allocs/op 111 allocs/op 111 allocs/op 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.