|
@@ -35,7 +35,7 @@ type Store struct {
|
|
|
|
|
|
|
|
// The string channel to send messages to the outside world
|
|
// The string channel to send messages to the outside world
|
|
|
// Now we use it to send changes to the hub of the web service
|
|
// Now we use it to send changes to the hub of the web service
|
|
|
- messager *chan string
|
|
|
|
|
|
|
+ messager chan<- string
|
|
|
|
|
|
|
|
// A map to keep the recent response to the clients
|
|
// A map to keep the recent response to the clients
|
|
|
ResponseMap map[string]*Response
|
|
ResponseMap map[string]*Response
|
|
@@ -141,7 +141,7 @@ func CreateStore(max int) *Store {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Set the messager of the store
|
|
// Set the messager of the store
|
|
|
-func (s *Store) SetMessager(messager *chan string) {
|
|
|
|
|
|
|
+func (s *Store) SetMessager(messager chan<- string) {
|
|
|
s.messager = messager
|
|
s.messager = messager
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -224,8 +224,7 @@ func (s *Store) internalSet(key string, value string, expireTime time.Time, inde
|
|
|
|
|
|
|
|
// Send to the messager
|
|
// Send to the messager
|
|
|
if s.messager != nil && err == nil {
|
|
if s.messager != nil && err == nil {
|
|
|
-
|
|
|
|
|
- *s.messager <- string(msg)
|
|
|
|
|
|
|
+ s.messager <- string(msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
s.addToResponseMap(index, &resp)
|
|
s.addToResponseMap(index, &resp)
|
|
@@ -257,8 +256,7 @@ func (s *Store) internalSet(key string, value string, expireTime time.Time, inde
|
|
|
|
|
|
|
|
// Send to the messager
|
|
// Send to the messager
|
|
|
if s.messager != nil && err == nil {
|
|
if s.messager != nil && err == nil {
|
|
|
-
|
|
|
|
|
- *s.messager <- string(msg)
|
|
|
|
|
|
|
+ s.messager <- string(msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
s.addToResponseMap(index, &resp)
|
|
s.addToResponseMap(index, &resp)
|
|
@@ -440,8 +438,7 @@ func (s *Store) internalDelete(key string, index uint64) ([]byte, error) {
|
|
|
|
|
|
|
|
// notify the messager
|
|
// notify the messager
|
|
|
if s.messager != nil && err == nil {
|
|
if s.messager != nil && err == nil {
|
|
|
-
|
|
|
|
|
- *s.messager <- string(msg)
|
|
|
|
|
|
|
+ s.messager <- string(msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
s.addToResponseMap(index, &resp)
|
|
s.addToResponseMap(index, &resp)
|
|
@@ -526,8 +523,7 @@ func (s *Store) monitorExpiration(key string, update chan time.Time, expireTime
|
|
|
|
|
|
|
|
// notify the messager
|
|
// notify the messager
|
|
|
if s.messager != nil && err == nil {
|
|
if s.messager != nil && err == nil {
|
|
|
-
|
|
|
|
|
- *s.messager <- string(msg)
|
|
|
|
|
|
|
+ s.messager <- string(msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return
|
|
return
|