refactor: push commands in to cmd and ev to root as library

This commit is contained in:
Jon Lundy
2023-01-09 11:30:02 -07:00
parent 250395d6b3
commit 4fc9c78dae
58 changed files with 765 additions and 376 deletions

View File

@@ -19,8 +19,8 @@ import (
contentnegotiation "gitlab.com/jamietanna/content-negotiation-go"
"go.opentelemetry.io/otel/attribute"
"github.com/sour-is/ev"
"github.com/sour-is/ev/internal/lg"
"github.com/sour-is/ev/pkg/es"
"github.com/sour-is/ev/pkg/es/event"
)
@@ -150,7 +150,7 @@ func (s *service) getPending(w http.ResponseWriter, r *http.Request, peerID stri
return
}
info, err := es.Upsert(ctx, s.es, aggInfo, func(ctx context.Context, agg *Info) error {
info, err := ev.Upsert(ctx, s.es, aggInfo, func(ctx context.Context, agg *Info) error {
return agg.OnUpsert() // initialize if not exists
})
if err != nil {

View File

@@ -9,8 +9,8 @@ import (
"net/http"
"time"
"github.com/sour-is/ev"
"github.com/sour-is/ev/internal/lg"
"github.com/sour-is/ev/pkg/es"
"github.com/sour-is/ev/pkg/es/event"
"github.com/sour-is/ev/pkg/set"
)
@@ -151,7 +151,7 @@ func (s *service) cleanRequests(ctx context.Context, now time.Time) error {
for {
events, err := s.es.Read(ctx, queueRequests, startPosition, 1000) // read 1000 from the top each loop.
if err != nil && !errors.Is(err, es.ErrNotFound) {
if err != nil && !errors.Is(err, ev.ErrNotFound) {
span.RecordError(err)
return err
}

View File

@@ -6,8 +6,8 @@ import (
"sync/atomic"
"time"
"github.com/sour-is/ev"
"github.com/sour-is/ev/internal/lg"
"github.com/sour-is/ev/pkg/es"
"github.com/sour-is/ev/pkg/es/event"
"github.com/sour-is/ev/pkg/locker"
"go.uber.org/multierr"
@@ -24,7 +24,7 @@ func aggRequest(id string) string { return "pf-request-" + id }
func aggPeer(id string) string { return "pf-peer-" + id }
type service struct {
es *es.EventStore
es *ev.EventStore
statusURL string
state *locker.Locked[state]
@@ -37,7 +37,7 @@ type state struct {
requests map[string]*Request
}
func New(ctx context.Context, es *es.EventStore, statusURL string) (*service, error) {
func New(ctx context.Context, es *ev.EventStore, statusURL string) (*service, error) {
ctx, span := lg.Span(ctx)
defer span.End()