-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugins): Support caddy config reload for embedded olric (#214)
* fix(plugins): Support caddy config reload for embedded olric * Fix linter errors * Increase goyave waiting time
- Loading branch information
Showing
18 changed files
with
225 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package httpcache | ||
|
||
import ( | ||
"fmt" | ||
"sync" | ||
) | ||
|
||
const stored_providers_key = "STORED_PROVIDERS_KEY" | ||
|
||
type storage_providers struct { | ||
list map[interface{}]bool | ||
sync.RWMutex | ||
} | ||
|
||
func newStorageProvider() *storage_providers { | ||
return &storage_providers{ | ||
list: make(map[interface{}]bool), | ||
RWMutex: sync.RWMutex{}, | ||
} | ||
} | ||
|
||
func (s *storage_providers) Add(key interface{}) { | ||
s.RWMutex.Lock() | ||
defer s.RWMutex.Unlock() | ||
|
||
s.list[key] = true | ||
} | ||
|
||
func (s *SouinCaddyPlugin) Cleanup() error { | ||
fmt.Println("Cleanup...") | ||
td := []interface{}{} | ||
sp, _ := up.LoadOrStore(stored_providers_key, newStorageProvider()) | ||
stored_providers := sp.(*storage_providers) | ||
fmt.Println(stored_providers.list) | ||
up.Range(func(key, value interface{}) bool { | ||
if key != stored_providers_key { | ||
if !stored_providers.list[key] { | ||
td = append(td, key) | ||
} | ||
} | ||
|
||
return true | ||
}) | ||
|
||
for _, v := range td { | ||
fmt.Printf("Cleaning %v\n", v) | ||
up.Delete(v) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.