mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-05 16:06:57 +08:00
Removed debug print statements in acl.go file
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -101,6 +101,7 @@ type EchoVault struct {
|
|||||||
|
|
||||||
listener atomic.Value // Holds the TCP listener.
|
listener atomic.Value // Holds the TCP listener.
|
||||||
quit chan struct{} // Channel that signals the closing of all client connections.
|
quit chan struct{} // Channel that signals the closing of all client connections.
|
||||||
|
stopTTL chan struct{} // Channel that signals the TTL sampling goroutine to stop execution.
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContext is an options that for the NewEchoVault function that allows you to
|
// WithContext is an options that for the NewEchoVault function that allows you to
|
||||||
@@ -145,7 +146,8 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
|
|||||||
commands = append(commands, str.Commands()...)
|
commands = append(commands, str.Commands()...)
|
||||||
return commands
|
return commands
|
||||||
}(),
|
}(),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
|
stopTTL: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
@@ -274,9 +276,14 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
|
|||||||
if echovault.config.EvictionPolicy != constants.NoEviction {
|
if echovault.config.EvictionPolicy != constants.NoEviction {
|
||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(echovault.config.EvictionInterval)
|
ticker := time.NewTicker(echovault.config.EvictionInterval)
|
||||||
for _ = range ticker.C {
|
for {
|
||||||
if err := echovault.evictKeysWithExpiredTTL(context.Background()); err != nil {
|
select {
|
||||||
log.Printf("evict with ttl: %v\n", err)
|
case <-ticker.C:
|
||||||
|
if err := echovault.evictKeysWithExpiredTTL(context.Background()); err != nil {
|
||||||
|
log.Printf("evict with ttl: %v\n", err)
|
||||||
|
}
|
||||||
|
case <-echovault.stopTTL:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -555,6 +562,7 @@ func (server *EchoVault) rewriteAOF() error {
|
|||||||
func (server *EchoVault) ShutDown() {
|
func (server *EchoVault) ShutDown() {
|
||||||
if server.listener.Load() != nil {
|
if server.listener.Load() != nil {
|
||||||
go func() { server.quit <- struct{}{} }()
|
go func() { server.quit <- struct{}{} }()
|
||||||
|
go func() { server.stopTTL <- struct{}{} }()
|
||||||
log.Println("closing tcp listener...")
|
log.Println("closing tcp listener...")
|
||||||
if err := server.listener.Load().(net.Listener).Close(); err != nil {
|
if err := server.listener.Load().(net.Listener).Close(); err != nil {
|
||||||
log.Printf("listener close: %v\n", err)
|
log.Printf("listener close: %v\n", err)
|
||||||
|
@@ -70,14 +70,14 @@ func getBindAddr() net.IP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupServer(
|
func setupServer(
|
||||||
serverId string,
|
serverId string,
|
||||||
bootstrapCluster bool,
|
bootstrapCluster bool,
|
||||||
forwardCommand bool,
|
forwardCommand bool,
|
||||||
bindAddr,
|
bindAddr,
|
||||||
joinAddr string,
|
joinAddr string,
|
||||||
port,
|
port,
|
||||||
raftPort,
|
raftPort,
|
||||||
mlPort int,
|
mlPort int,
|
||||||
) (*EchoVault, error) {
|
) (*EchoVault, error) {
|
||||||
conf := DefaultConfig()
|
conf := DefaultConfig()
|
||||||
conf.DataDir = "./testdata"
|
conf.DataDir = "./testdata"
|
||||||
|
@@ -435,8 +435,6 @@ func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command intern
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 9. Check if write keys are in IncludedWriteKeys
|
// 9. Check if write keys are in IncludedWriteKeys
|
||||||
fmt.Println("KEYS: ", writeKeys)
|
|
||||||
fmt.Println("ALLOWED KEYS: ", connection.User.IncludedWriteKeys)
|
|
||||||
if !slices.ContainsFunc(writeKeys, func(key string) bool {
|
if !slices.ContainsFunc(writeKeys, func(key string) bool {
|
||||||
return slices.ContainsFunc(connection.User.IncludedWriteKeys, func(writeKeyGlob string) bool {
|
return slices.ContainsFunc(connection.User.IncludedWriteKeys, func(writeKeyGlob string) bool {
|
||||||
if acl.GlobPatterns[writeKeyGlob].Match(key) {
|
if acl.GlobPatterns[writeKeyGlob].Match(key) {
|
||||||
|
Reference in New Issue
Block a user