This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plancontext/service.go

30 lines
442 B
Go
Raw Normal View History

package plancontext
import "sync"
type serviceContext struct {
l sync.RWMutex
store map[ContextKey]*Service
}
type Service struct {
Unix string
Npipe string
}
func (c *serviceContext) Register(service *Service) ContextKey {
c.l.Lock()
defer c.l.Unlock()
id := hashID(service)
c.store[id] = service
return id
}
func (c *serviceContext) Get(id ContextKey) *Service {
c.l.RLock()
defer c.l.RUnlock()
return c.store[id]
}