fix: merge
This commit is contained in:
parent
23639bc306
commit
fd97f2ff17
6
main.go
6
main.go
|
@ -1,17 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"github.com/99designs/gqlgen/graphql/handler"
|
"github.com/99designs/gqlgen/graphql/handler"
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/sour-is/ev/api/gql_ev"
|
"github.com/sour-is/ev/api/gql_ev"
|
||||||
"github.com/sour-is/ev/internal/graph"
|
"github.com/sour-is/ev/internal/graph"
|
||||||
|
@ -67,7 +67,7 @@ func run(ctx context.Context) error {
|
||||||
"endpoint": "https://ev.sour.is/inbox/01GA4Q3NDX4TPAZ2EZ8E92CQE6",
|
"endpoint": "https://ev.sour.is/inbox/01GA4Q3NDX4TPAZ2EZ8E92CQE6",
|
||||||
"key": "kex1pqwqatj6sge7qaqrsvk4u4yhue4x3vej8znetkwj6a5k0xds2fmqqe3plh"
|
"key": "kex1pqwqatj6sge7qaqrsvk4u4yhue4x3vej8znetkwj6a5k0xds2fmqqe3plh"
|
||||||
}`)
|
}`)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
mux.Handle("/.well-known/salty/0ce550020ce36a9932b286b141edd515d33c2b0f51c715445de89ae106345993.json", wk)
|
mux.Handle("/.well-known/salty/0ce550020ce36a9932b286b141edd515d33c2b0f51c715445de89ae106345993.json", wk)
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,12 @@ import (
|
||||||
"github.com/sour-is/ev/pkg/math"
|
"github.com/sour-is/ev/pkg/math"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type openlogs struct {
|
||||||
|
logs map[string]*locker.Locked[wal.Log]
|
||||||
|
}
|
||||||
type diskStore struct {
|
type diskStore struct {
|
||||||
path string
|
path string
|
||||||
|
openlogs *locker.Locked[openlogs]
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppendOnly = es.AppendOnly
|
const AppendOnly = es.AppendOnly
|
||||||
|
@ -48,13 +52,26 @@ func (diskStore) Open(_ context.Context, dsn string) (driver.Driver, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &diskStore{path: path}, nil
|
logs := &openlogs{logs: make(map[string]*locker.Locked[wal.Log])}
|
||||||
|
return &diskStore{path: path, openlogs: locker.New(logs)}, nil
|
||||||
}
|
}
|
||||||
func (ds *diskStore) EventLog(ctx context.Context, streamID string) (driver.EventLog, error) {
|
func (ds *diskStore) EventLog(ctx context.Context, streamID string) (driver.EventLog, error) {
|
||||||
el := &eventLog{streamID: streamID}
|
el := &eventLog{streamID: streamID}
|
||||||
l, err := wal.Open(filepath.Join(ds.path, streamID), wal.DefaultOptions)
|
|
||||||
el.events = locker.New(l)
|
return el, ds.openlogs.Modify(ctx, func(openlogs *openlogs) error {
|
||||||
return el, err
|
if events, ok := openlogs.logs[streamID]; ok {
|
||||||
|
el.events = events
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err := wal.Open(filepath.Join(ds.path, streamID), wal.DefaultOptions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
el.events = locker.New(l)
|
||||||
|
openlogs.logs[streamID] = el.events
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventLog struct {
|
type eventLog struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user