mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 06:06:03 -06:00
registry: log subscribe/unsubscribe messages only when the action actually takes place
This commit is contained in:
parent
c2c50bfba6
commit
1700712f7f
1 changed files with 12 additions and 12 deletions
24
registry.go
24
registry.go
|
|
@ -54,12 +54,6 @@ var voidRegistryItem = &RegistryItem{}
|
|||
|
||||
// Subscribe allows to connect client with a given identifier.
|
||||
func (r *registry) Subscribe(identifier id.ID) {
|
||||
r.logger.Log(
|
||||
"level", 1,
|
||||
"action", "subscribe",
|
||||
"identifier", identifier,
|
||||
)
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
|
|
@ -67,6 +61,12 @@ func (r *registry) Subscribe(identifier id.ID) {
|
|||
return
|
||||
}
|
||||
|
||||
r.logger.Log(
|
||||
"level", 1,
|
||||
"action", "subscribe",
|
||||
"identifier", identifier,
|
||||
)
|
||||
|
||||
r.items[identifier] = voidRegistryItem
|
||||
}
|
||||
|
||||
|
|
@ -93,12 +93,6 @@ func (r *registry) Subscriber(hostPort string) (id.ID, *Auth, bool) {
|
|||
|
||||
// Unsubscribe removes client from registry and returns it's RegistryItem.
|
||||
func (r *registry) Unsubscribe(identifier id.ID) *RegistryItem {
|
||||
r.logger.Log(
|
||||
"level", 1,
|
||||
"action", "unsubscribe",
|
||||
"identifier", identifier,
|
||||
)
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
|
|
@ -107,6 +101,12 @@ func (r *registry) Unsubscribe(identifier id.ID) *RegistryItem {
|
|||
return nil
|
||||
}
|
||||
|
||||
r.logger.Log(
|
||||
"level", 1,
|
||||
"action", "unsubscribe",
|
||||
"identifier", identifier,
|
||||
)
|
||||
|
||||
if i.Hosts != nil {
|
||||
for _, h := range i.Hosts {
|
||||
delete(r.hosts, h.Host)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue