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.
|
||||
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
|
||||
@@ -146,6 +147,7 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
|
||||
return commands
|
||||
}(),
|
||||
quit: make(chan struct{}),
|
||||
stopTTL: make(chan struct{}),
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
@@ -274,10 +276,15 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
|
||||
if echovault.config.EvictionPolicy != constants.NoEviction {
|
||||
go func() {
|
||||
ticker := time.NewTicker(echovault.config.EvictionInterval)
|
||||
for _ = range ticker.C {
|
||||
for {
|
||||
select {
|
||||
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() {
|
||||
if server.listener.Load() != nil {
|
||||
go func() { server.quit <- struct{}{} }()
|
||||
go func() { server.stopTTL <- struct{}{} }()
|
||||
log.Println("closing tcp listener...")
|
||||
if err := server.listener.Load().(net.Listener).Close(); err != nil {
|
||||
log.Printf("listener close: %v\n", err)
|
||||
|
@@ -435,8 +435,6 @@ func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command intern
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return slices.ContainsFunc(connection.User.IncludedWriteKeys, func(writeKeyGlob string) bool {
|
||||
if acl.GlobPatterns[writeKeyGlob].Match(key) {
|
||||
|
Reference in New Issue
Block a user