-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata access rule #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove unused parameters and configs...
backends/etcdv3/client.go
Outdated
@@ -209,39 +274,50 @@ func (c *Client) internalSync(prefix string, store store.Store, stopChan chan bo | |||
}() | |||
|
|||
for !init { | |||
val, err := c.internalGets(prefix, "/") | |||
err := initStoreFunc() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 在这个for !init {}里面是否要加个判断stopChan的条件退出循环?
- 这个cancelRoutine和stopChan没看太明白,能否直接用
select {
case <- stopChan:
cancel()
return
default:
}
为什么还需要使用cancelRoutine来控制退出的循环呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个已经重构。
- !init {} 的退出条件已经检测。
- cancelRoutine 原来用错了,这个是用来确保读取 stopChan 那个 goroutine 正确退出的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看internalSync里还有cancelRoutine,这个还有用吗?是不是可以删了?
store/access.go
Outdated
} | ||
child := curr.GetChild(component, true) | ||
if child == nil { | ||
child = &AccessNode{Name: component, Mode: AccessModeNil, parent: curr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当前node默认为AccessModeNil的权限,比如/c1/c2/c3 ,如果用户拥有/c1的写权限,他并没有/c1/c2的写权限吗?有考虑子key继承父key的权限吗?
begin = AccessMode(-2) | ||
AccessModeNil = AccessMode(-1) | ||
AccessModeForbidden = AccessMode(0) | ||
AccessModeRead = AccessMode(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个权限够用吗?有Read, Write,Read/Write的需求吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write 有需求可以加,加的时候把 end 往后挪就行。
return r.changeToResult(w, ctx.Done()) | ||
} | ||
w := r.data.Watch(nodePath, DEFAULT_WATCH_BUF_LEN) | ||
return r.changeToResult(w, ctx.Done()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changeToResult 里是不是可以直接用 case <-time.After(n * time.Second)的timer来处理超时呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个请求比较频繁,所以弄了个 timePool 控制。
return val | ||
if traveller.Enter(nodePath) { | ||
val := traveller.GetValue() | ||
traveller.BackToRoot() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在连续get某个key的时候,下一个key存在这个curr node的兄弟或子节点概率大吧,在这个时候backToRoot不是过早了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是 self 的 mapping,记录的路径是绝对路径,如果不 backToRoot,要计算和上一次获取数据的请求的相对路径,比较难实现。
backends/etcdv3/client.go
Outdated
@@ -209,39 +274,50 @@ func (c *Client) internalSync(prefix string, store store.Store, stopChan chan bo | |||
}() | |||
|
|||
for !init { | |||
val, err := c.internalGets(prefix, "/") | |||
err := initStoreFunc() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看internalSync里还有cancelRoutine,这个还有用吗?是不是可以删了?
通过独立定义访问规则的方式来限制节点获取 metadata 的范围。
新增接口:/v1/rule 用于提交访问规则。
PUT|POST: 修改,每个 ip 提交的访问规则会直接替换以前该 ip 的所有规则。
GET: 获取
返回值同 POST,传递参数 hosts 表示要获取的访问规则的 ip,多个用逗号隔开,不传递表示获取全部。
DELETE: 删除
传递参数 hosts 表示要删除的访问规则的 ip,多个用逗号隔开。
访问规则定义说明:
访问规则模式说明:
访问规则路径的特殊说明:
比如以下规则: