mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-30 13:51:52 +02:00
feat(docker): implement container ID to Docker host mapping
This commit is contained in:
21
internal/docker/id_lookup.go
Normal file
21
internal/docker/id_lookup.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/puzpuzpuz/xsync/v4"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var idDockerHostMap = xsync.NewMap[string, string](xsync.WithPresize(100))
|
||||
|
||||
func GetDockerHostByContainerID(id string) (string, bool) {
|
||||
return idDockerHostMap.Load(id)
|
||||
}
|
||||
|
||||
func SetDockerHostByContainerID(id, host string) {
|
||||
log.Debug().Str("id", id).Str("host", host).Int("size", idDockerHostMap.Size()).Msg("setting docker host by container id")
|
||||
idDockerHostMap.Store(id, host)
|
||||
}
|
||||
|
||||
func DeleteDockerHostByContainerID(id string) {
|
||||
idDockerHostMap.Delete(id)
|
||||
}
|
||||
Reference in New Issue
Block a user