Add documentation
This commit is contained in:
		
							parent
							
								
									81c4d15d9f
								
							
						
					
					
						commit
						9be6bfc5fa
					
				@ -10,18 +10,26 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Internal function for the timer logic thread.
 | 
				
			||||||
func cacheTimerLogic(waiting bool) {
 | 
					func cacheTimerLogic(waiting bool) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Case: This server goes down now.
 | 
				
			||||||
	if Shutdown.IsDown() {
 | 
						if Shutdown.IsDown() {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Define the query and get the iterator:
 | 
				
			||||||
	lastCount := cacheListenerDatabase.Len()
 | 
						lastCount := cacheListenerDatabase.Len()
 | 
				
			||||||
	selection := bson.D{{`IsActive`, true}}
 | 
						selection := bson.D{{`IsActive`, true}}
 | 
				
			||||||
	entriesIterator := collectionListener.Find(selection).Iter()
 | 
						entriesIterator := collectionListener.Find(selection).Iter()
 | 
				
			||||||
	entry := Scheme.Listener{}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						entry := Scheme.Listener{}
 | 
				
			||||||
	cacheListenerDatabaseLock.Lock()
 | 
						cacheListenerDatabaseLock.Lock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Re-init the cache:
 | 
				
			||||||
	cacheListenerDatabase.Init()
 | 
						cacheListenerDatabase.Init()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Loop over all entries
 | 
				
			||||||
	for entriesIterator.Next(&entry) {
 | 
						for entriesIterator.Next(&entry) {
 | 
				
			||||||
		cacheListenerDatabase.PushBack(entry)
 | 
							cacheListenerDatabase.PushBack(entry)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -29,6 +37,7 @@ func cacheTimerLogic(waiting bool) {
 | 
				
			|||||||
	cacheListenerDatabaseLock.Unlock()
 | 
						cacheListenerDatabaseLock.Unlock()
 | 
				
			||||||
	Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameEXECUTE, `The listener cache was refreshed with the values from the database.`, fmt.Sprintf(`last count=%d`, lastCount), fmt.Sprintf(`new count=%d`, cacheListenerDatabase.Len()))
 | 
						Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameEXECUTE, `The listener cache was refreshed with the values from the database.`, fmt.Sprintf(`last count=%d`, lastCount), fmt.Sprintf(`new count=%d`, cacheListenerDatabase.Len()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// In case, that this function runs at a thread, we want to wait:
 | 
				
			||||||
	if waiting {
 | 
						if waiting {
 | 
				
			||||||
		nextDuration := time.Duration(5) * time.Minute
 | 
							nextDuration := time.Duration(5) * time.Minute
 | 
				
			||||||
		if cacheListenerDatabase.Len() == 0 {
 | 
							if cacheListenerDatabase.Len() == 0 {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user