From 4b4d3b743dd82a43bf87f727e0d4f44315aa7899 Mon Sep 17 00:00:00 2001 From: Jon Lundy Date: Sun, 20 Nov 2022 10:26:20 -0700 Subject: [PATCH] chore: go fmt --- Makefile | 2 +- app/salty/salty-addr.go | 1 + app/salty/salty-user.go | 1 + app/salty/service.go | 2 +- httpmux.go | 5 ++--- pkg/es/driver/disk-store/disk-store.go | 10 ++++------ pkg/es/driver/projecter/projecter.go | 1 - pkg/es/es.go | 2 +- pkg/es/event/reflect.go | 2 +- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index e3072ec..a11a1b8 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif air run: - go run . + go run . test: go test -cover -race ./... diff --git a/app/salty/salty-addr.go b/app/salty/salty-addr.go index 3db2630..132c2fd 100644 --- a/app/salty/salty-addr.go +++ b/app/salty/salty-addr.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/keys-pub/keys" + "github.com/sour-is/ev/internal/lg" ) diff --git a/app/salty/salty-user.go b/app/salty/salty-user.go index 9ab4c93..5a5b15b 100644 --- a/app/salty/salty-user.go +++ b/app/salty/salty-user.go @@ -11,6 +11,7 @@ import ( "github.com/keys-pub/keys" "github.com/oklog/ulid/v2" + "github.com/sour-is/ev/pkg/es/event" "github.com/sour-is/ev/pkg/gql" ) diff --git a/app/salty/service.go b/app/salty/service.go index a396254..ad98c25 100644 --- a/app/salty/service.go +++ b/app/salty/service.go @@ -12,13 +12,13 @@ import ( "strings" "time" + "github.com/keys-pub/keys" "go.mills.io/saltyim" "go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument/syncint64" "go.opentelemetry.io/otel/metric/unit" "go.uber.org/multierr" - "github.com/keys-pub/keys" "github.com/sour-is/ev/internal/lg" "github.com/sour-is/ev/pkg/es" "github.com/sour-is/ev/pkg/es/event" diff --git a/httpmux.go b/httpmux.go index 811ac58..ed40f0f 100644 --- a/httpmux.go +++ b/httpmux.go @@ -1,7 +1,6 @@ package main import ( - "log" "net/http" "github.com/rs/cors" @@ -18,7 +17,6 @@ func httpMux(fns ...interface{ RegisterHTTP(*http.ServeMux) }) http.Handler { fn.RegisterHTTP(mux.ServeMux) if fn, ok := fn.(interface{ RegisterAPIv1(*http.ServeMux) }); ok { - log.Printf("register api %T", fn) fn.RegisterAPIv1(mux.api) } } @@ -36,6 +34,7 @@ func newMux() *mux { } type RegisterHTTP func(*http.ServeMux) + func (fn RegisterHTTP) RegisterHTTP(mux *http.ServeMux) { fn(mux) -} \ No newline at end of file +} diff --git a/pkg/es/driver/disk-store/disk-store.go b/pkg/es/driver/disk-store/disk-store.go index b502c02..3601ae8 100644 --- a/pkg/es/driver/disk-store/disk-store.go +++ b/pkg/es/driver/disk-store/disk-store.go @@ -188,7 +188,6 @@ func (e *eventLog) Append(ctx context.Context, events event.Events, version uint attribute.Int64("args.version", int64(version)), attribute.String("streamID", e.streamID), attribute.String("path", e.diskStore.path), - ) event.SetStreamID(e.streamID, events...) @@ -279,7 +278,6 @@ func (e *eventLog) Read(ctx context.Context, after, count int64) (event.Events, attribute.Int64("start", int64(start)), attribute.Int64("count", int64(count)), attribute.Int64("after", int64(after)), - ) events = make([]event.Event, math.Abs(count)) @@ -322,7 +320,7 @@ func (e *eventLog) ReadN(ctx context.Context, index ...uint64) (event.Events, er lis := make([]int64, len(index)) for i := range index { - lis[i]=int64(index[i]) + lis[i] = int64(index[i]) } span.SetAttributes( @@ -345,7 +343,7 @@ func (e *eventLog) ReadN(ctx context.Context, index ...uint64) (event.Events, er func (e *eventLog) FirstIndex(ctx context.Context) (uint64, error) { ctx, span := lg.Span(ctx) defer span.End() - + span.SetAttributes( attribute.String("streamID", e.streamID), attribute.String("path", e.diskStore.path), @@ -383,7 +381,7 @@ func (e *eventLog) LastIndex(ctx context.Context) (uint64, error) { func (e *eventLog) Truncate(ctx context.Context, index int64) error { ctx, span := lg.Span(ctx) defer span.End() - + span.SetAttributes( attribute.Int64("args.index", index), attribute.String("streamID", e.streamID), @@ -432,7 +430,7 @@ func readStreamN(ctx context.Context, stream *wal.Log, index ...uint64) (event.E lis := make([]int64, len(index)) for i := range index { - lis[i]=int64(index[i]) + lis[i] = int64(index[i]) } span.SetAttributes( diff --git a/pkg/es/driver/projecter/projecter.go b/pkg/es/driver/projecter/projecter.go index 414d652..ea1ea45 100644 --- a/pkg/es/driver/projecter/projecter.go +++ b/pkg/es/driver/projecter/projecter.go @@ -118,7 +118,6 @@ func (w *wrapper) LastIndex(ctx context.Context) (uint64, error) { return w.up.LastIndex(ctx) } - func DefaultProjection(e event.Event) []event.Event { m := e.EventMeta() streamID := m.StreamID diff --git a/pkg/es/es.go b/pkg/es/es.go index db994e6..70204d0 100644 --- a/pkg/es/es.go +++ b/pkg/es/es.go @@ -274,7 +274,7 @@ func (es *EventStore) EventStream() driver.EventStream { func (es *EventStore) Truncate(ctx context.Context, streamID string, index int64) error { ctx, span := lg.Span(ctx) defer span.End() - + up, err := es.Driver.EventLog(ctx, streamID) if err != nil { return err diff --git a/pkg/es/event/reflect.go b/pkg/es/event/reflect.go index a433592..e62f116 100644 --- a/pkg/es/event/reflect.go +++ b/pkg/es/event/reflect.go @@ -124,7 +124,7 @@ func GetContainer(ctx context.Context, s string) Event { var e Event - eventTypes.Modify(ctx, func(ctx context.Context,c *config) error { + eventTypes.Modify(ctx, func(ctx context.Context, c *config) error { _, span := lg.Span(ctx) defer span.End()