mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Adjust comments. Change DefaultSecurityManager to NopSecurityManager.
This commit is contained in:
parent
fc829b08e8
commit
da0184f728
3 changed files with 28 additions and 24 deletions
28
cluster.go
28
cluster.go
|
|
@ -186,7 +186,7 @@ func NewCluster() *Cluster {
|
|||
closing: make(chan struct{}),
|
||||
|
||||
LogOutput: os.Stderr,
|
||||
prefect: &DefaultSecurityManager{},
|
||||
prefect: &NopSecurityManager{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,20 +228,20 @@ func (c *Cluster) NodeSet() []URI {
|
|||
}
|
||||
|
||||
func (c *Cluster) setState(state string) {
|
||||
if c.State != state { //only on new state, perform routing change
|
||||
switch state {
|
||||
case ClusterStateResizing:
|
||||
c.prefect.SetRestricted()
|
||||
case ClusterStateNormal:
|
||||
c.prefect.SetNormal()
|
||||
// Don't change routing for these new states
|
||||
// ClusterStateStarting
|
||||
// ResizeJobStateRunning
|
||||
// ResizeJobStateDone
|
||||
// ResizeJobStateAborted
|
||||
|
||||
}
|
||||
// Ignore cases where the state hasn't changed.
|
||||
if state == c.State {
|
||||
return
|
||||
}
|
||||
|
||||
switch state {
|
||||
case ClusterStateResizing:
|
||||
c.prefect.SetRestricted()
|
||||
case ClusterStateNormal:
|
||||
c.prefect.SetNormal()
|
||||
// Don't change routing for these states:
|
||||
// - ClusterStateStarting
|
||||
}
|
||||
|
||||
c.State = state
|
||||
}
|
||||
|
||||
|
|
|
|||
10
handler.go
10
handler.go
|
|
@ -95,25 +95,29 @@ func NewHandler() *Handler {
|
|||
return handler
|
||||
}
|
||||
|
||||
// BuildRouters creates a Gorilla Mux http routers for both normal and restricted enpoints.
|
||||
// BuildRouters creates Gorilla Mux http routers for both normal and restricted endpoints.
|
||||
func BuildRouters(handler *Handler) {
|
||||
// Normal router.
|
||||
router := mux.NewRouter()
|
||||
loadCommon(router, handler)
|
||||
loadNormal(router, handler)
|
||||
handler.NormalRouter = router
|
||||
|
||||
// Restricted router.
|
||||
router = mux.NewRouter()
|
||||
loadCommon(router, handler)
|
||||
loadRestricted(router, handler)
|
||||
handler.RestrictedRouter = router
|
||||
|
||||
handler.SetNormal()
|
||||
}
|
||||
|
||||
// SetNormal a method of the SecurityManager interface which provides normal URI routing
|
||||
// SetNormal is a method of the SecurityManager interface which provides normal URI routing.
|
||||
func (h *Handler) SetNormal() {
|
||||
h.Router = h.NormalRouter
|
||||
}
|
||||
|
||||
// SetRestricted a method of the SecurityManager interface which provides restricted URI routing
|
||||
// SetRestricted is a method of the SecurityManager interface which provides restricted URI routing.
|
||||
func (h *Handler) SetRestricted() {
|
||||
h.Router = h.RestrictedRouter
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
package pilosa
|
||||
|
||||
// SecurityManager provides the ability to limit access to restricted endpoints
|
||||
// during cluster configuration
|
||||
// during cluster configuration.
|
||||
type SecurityManager interface {
|
||||
SetRestricted()
|
||||
SetNormal()
|
||||
}
|
||||
|
||||
// DefaultSecurityManager provides a no-op implimentation of the SecurityManager interface
|
||||
type DefaultSecurityManager struct {
|
||||
// NopSecurityManager provides a no-op implementation of the SecurityManager interface.
|
||||
type NopSecurityManager struct {
|
||||
}
|
||||
|
||||
// SetRestricted no-op
|
||||
func (sdm *DefaultSecurityManager) SetRestricted() {
|
||||
// SetRestricted no-op.
|
||||
func (sdm *NopSecurityManager) SetRestricted() {
|
||||
|
||||
}
|
||||
|
||||
// SetNormal no-op
|
||||
func (sdm *DefaultSecurityManager) SetNormal() {
|
||||
// SetNormal no-op.
|
||||
func (sdm *NopSecurityManager) SetNormal() {
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue