code cleanup
This commit is contained in:
27
app/state.go
Normal file
27
app/state.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import "sync"
|
||||
|
||||
// Global state management
|
||||
var (
|
||||
interactionStates = make(map[string]*InteractionState)
|
||||
interactionStatesMutex = sync.RWMutex{}
|
||||
)
|
||||
|
||||
func getInteractionState(token string) *InteractionState {
|
||||
interactionStatesMutex.RLock()
|
||||
defer interactionStatesMutex.RUnlock()
|
||||
return interactionStates[token]
|
||||
}
|
||||
|
||||
func setInteractionState(token string, state *InteractionState) {
|
||||
interactionStatesMutex.Lock()
|
||||
defer interactionStatesMutex.Unlock()
|
||||
interactionStates[token] = state
|
||||
}
|
||||
|
||||
func deleteInteractionState(token string) {
|
||||
interactionStatesMutex.Lock()
|
||||
defer interactionStatesMutex.Unlock()
|
||||
delete(interactionStates, token)
|
||||
}
|
||||
Reference in New Issue
Block a user