Port envd from e2b with internalized shared packages and Connect RPC
- Copy envd source from e2b-dev/infra, internalize shared dependencies
into envd/internal/shared/ (keys, filesystem, id, smap, utils)
- Switch from gRPC to Connect RPC for all envd services
- Update module paths to git.omukk.dev/wrenn/{sandbox,sandbox/envd}
- Add proto specs (process, filesystem) with buf-based code generation
- Implement full envd: process exec, filesystem ops, port forwarding,
cgroup management, MMDS integration, and HTTP API
- Update main module dependencies (firecracker SDK, pgx, goose, etc.)
- Remove placeholder .gitkeep files replaced by real implementations
This commit is contained in:
47
envd/internal/shared/smap/smap.go
Normal file
47
envd/internal/shared/smap/smap.go
Normal file
@ -0,0 +1,47 @@
|
||||
package smap
|
||||
|
||||
import (
|
||||
cmap "github.com/orcaman/concurrent-map/v2"
|
||||
)
|
||||
|
||||
type Map[V any] struct {
|
||||
m cmap.ConcurrentMap[string, V]
|
||||
}
|
||||
|
||||
func New[V any]() *Map[V] {
|
||||
return &Map[V]{
|
||||
m: cmap.New[V](),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map[V]) Remove(key string) {
|
||||
m.m.Remove(key)
|
||||
}
|
||||
|
||||
func (m *Map[V]) Get(key string) (V, bool) {
|
||||
return m.m.Get(key)
|
||||
}
|
||||
|
||||
func (m *Map[V]) Insert(key string, value V) {
|
||||
m.m.Set(key, value)
|
||||
}
|
||||
|
||||
func (m *Map[V]) Upsert(key string, value V, cb cmap.UpsertCb[V]) V {
|
||||
return m.m.Upsert(key, value, cb)
|
||||
}
|
||||
|
||||
func (m *Map[V]) InsertIfAbsent(key string, value V) bool {
|
||||
return m.m.SetIfAbsent(key, value)
|
||||
}
|
||||
|
||||
func (m *Map[V]) Items() map[string]V {
|
||||
return m.m.Items()
|
||||
}
|
||||
|
||||
func (m *Map[V]) RemoveCb(key string, cb func(key string, v V, exists bool) bool) bool {
|
||||
return m.m.RemoveCb(key, cb)
|
||||
}
|
||||
|
||||
func (m *Map[V]) Count() int {
|
||||
return m.m.Count()
|
||||
}
|
||||
Reference in New Issue
Block a user