Closed gedw99 closed 1 year ago
I just created a cmd/app-local/main.go to ge tthe job done for now.
package main
import (
"context"
"errors"
"flag"
"fmt"
"log"
"time"
_ "net/http/pprof"
"github.com/richardartoul/nola/virtual"
"github.com/richardartoul/nola/virtual/registry"
"github.com/richardartoul/nola/virtual/registry/localregistry"
"github.com/google/uuid"
)
var (
port = flag.Int("port", 9090, "TCP port for HTTP server to bind")
serverID = flag.String("serverID", uuid.New().String(), "ID to identify the server. Must be globally unique within the cluster")
discoveryType = flag.String("discoveryType", virtual.DiscoveryTypeLocalHost, "how the server should register itself with the discovery serice. Valid options: localhost|remote. Use localhost for local testing, use remote for multi-node setups")
registryType = flag.String("registryBackend", "memory", "backend to use for the Registry. Validation options: memory|foundationdb")
foundationDBClusterFilePath = flag.String("foundationDBClusterFilePath", "", "path to use for the FoundationDB cluster file")
)
func main() {
flag.Parse()
flag.VisitAll(func(f *flag.Flag) {
fmt.Printf(" --%s=%s\n", f.Name, f.Value.String())
})
var reg registry.Registry
switch *registryType {
case "memory":
reg = localregistry.NewLocalRegistry()
case "foundationdb":
err := errors.New("oops")
log.Fatalf("error creating FoundationDB registry: %v\n", err)
default:
log.Fatalf("unknown registry type: %v", *registryType)
}
client := virtual.NewHTTPClient()
ctx, cc := context.WithTimeout(context.Background(), 10*time.Second)
environment, err := virtual.NewEnvironment(ctx, *serverID, reg, client, virtual.EnvironmentOptions{
Discovery: virtual.DiscoveryOptions{
DiscoveryType: *discoveryType,
Port: *port,
},
})
cc()
if err != nil {
log.Fatal(err)
}
server := virtual.NewServer(reg, environment)
log.Printf("listening on port: %d\n", *port)
if err := server.Start(*port); err != nil {
log.Fatal(err)
}
}
go run cmd/app-local/main.go --discoveryType=localhost --registryBackend=memory
--alsologtostderr=false
--discoveryType=localhost
--foundationDBClusterFilePath=
--log_backtrace_at=:0
--log_dir=
--logtostderr=false
--port=9090
--registryBackend=memory
--serverID=b10bdec5-167a-4396-b210-5778eebb22f7
--stderrthreshold=2
--v=0
--vmodule=
2023/03/16 11:34:33 registering self with address: 127.0.0.1:9090
2023/03/16 11:34:33 listening on port: 9090
@richardartoul Do you want a PR ? Or happy to copy past that in for now ?
I’ll take a P.R. Build tag solution seems reasonable, although if that is too tricky I’ll take the copy paste for now lol
I think I jumped the gun…don’t want to be the technical debt creator :)
Is there a docker if Foundation db ? Can just use that.
And I saw a postres backstore floating around as a PR which negates my idea.
hell we are talking about Indexdb in another issue too for blobs but it is a kv so can also be a third backing store.
So I this issue is YAGNI …
let’s visit indexdb ideas in other issue
Will close
because Foundation DB is not easy to get going but i want to play, how about is we use build tags ?