casbin / redis-watcher

Redis WatcherEx for Casbin

Home Page:https://github.com/casbin/casbin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] redis-watcher's partial implementation of the WatcherEx interface

JalinWang opened this issue Β· comments

Though claimed in the code, the Redis Watcher doesn't implement the WatcherEx indeed.

This is a part of fixing for Casbin Issue 999.

Related issue: #1

The definition of the WatherEx interface:

type WatcherEx interface {
	Watcher
	UpdateForAddPolicy(sec, ptype string, params ...string) error
	UpdateForRemovePolicy(sec, ptype string, params ...string) error
	UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error
	UpdateForSavePolicy(model model.Model) error

	// *****NOT implemented*****
	UpdateForAddPolicies(sec string, ptype string, rules ...[]string) error
	UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) error
}

Currently implemented methods:
image

For the next, I will find somewhere to put the default update handler on receiving the update message from Redis.

Though this handler should involve changing the behavior in the casbin core repo, I prefer to put it here(redis-watcher repo). It seems not to be a generic one and depends on the emitted update message format.
image

Any suggestion?

For the next, I will find somewhere to put the default update handler on receiving the update message from Redis.

Though this handler should involve changing the behavior in the casbin core repo, I prefer to put it here(redis-watcher repo). It seems not to be a general one and depends on the emitted update message format. image

Any suggestion?

@JalinWang

  1. For watcherEx, if the user does not pass in the callback function parameter, we should provide a default implementation of the callback function when creating the watcher.
  2. For Casbin SetWatcher compatibility, determine whether the incoming watcher implements watcheEx interface. If not, keep it as it is. If so, the callback should not be set, because we cannot provide a generic implementation, which should be determined by the watcher itself

@hsluoyz @JalinWang I think this should be enhancement label instead of BugπŸ˜„

@hsluoyz @JalinWang I think this should be enhancement label instead of BugπŸ˜„

Agree. It's assigned by the bot and I have no permission to change it.

πŸŽ‰ This issue has been resolved in version 0.4.0 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€