From 34143d063f7957fdee7ce125dc31ce6ebe084301 Mon Sep 17 00:00:00 2001 From: Ara Park Date: Fri, 1 Dec 2023 21:26:28 +0900 Subject: [PATCH] refactor: consistence style (#30) --- README.md | 2 +- cmd/uniflow/main.go | 2 +- pkg/scheme/codec.go | 13 ++++++------- pkg/storage/event.go | 15 +++++++-------- pkg/storage/stream.go | 14 ++++++-------- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 300c5fe7..83b3b4b4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Configuration can be done using `.uniflow.toml` or system environment variables. | TOML Key | Env Key | Default | |---|---|---| -| database.url | DATABASE.URL | memdb:// | +| database.url | DATABASE.URL | mem:// or mongodb:// | | database.name | DATABASE.NAME | | diff --git a/cmd/uniflow/main.go b/cmd/uniflow/main.go index f5b5948c..9ea02273 100644 --- a/cmd/uniflow/main.go +++ b/cmd/uniflow/main.go @@ -96,7 +96,7 @@ func loadDB(ctx context.Context) (database.Database, error) { dbURL := viper.GetString(FlagDatabaseURL) dbName := viper.GetString(FlagDatabaseName) - if dbURL == "" || strings.HasPrefix(dbURL, "memdb://") { + if dbURL == "" || strings.HasPrefix(dbURL, "mem://") { return memdb.New(dbName), nil } else if strings.HasPrefix(dbURL, "mongodb://") { serverAPI := options.ServerAPI(options.ServerAPIVersion1) diff --git a/pkg/scheme/codec.go b/pkg/scheme/codec.go index 5e184f73..d76e459e 100644 --- a/pkg/scheme/codec.go +++ b/pkg/scheme/codec.go @@ -6,14 +6,13 @@ import ( "github.com/siyul-park/uniflow/pkg/node" ) -type ( - // Codec is the interface for decoding Spec to node.Node. - Codec interface { - Decode(spec Spec) (node.Node, error) - } +// Codec is the interface for decoding Spec to node.Node. +type Codec interface { + Decode(spec Spec) (node.Node, error) +} - CodecFunc func(spec Spec) (node.Node, error) -) +// CodecFunc is a function type that implements the Codec interface. +type CodecFunc func(spec Spec) (node.Node, error) // CodecWithType creates a new CodecFunc for the specified type T. func CodecWithType[T Spec](decode func(spec T) (node.Node, error)) Codec { diff --git a/pkg/storage/event.go b/pkg/storage/event.go index 872dafd5..c2328043 100644 --- a/pkg/storage/event.go +++ b/pkg/storage/event.go @@ -2,14 +2,13 @@ package storage import "github.com/oklog/ulid/v2" -type ( - // Event is an event that occurs when a scheme.Spec is changed. - Event struct { - OP eventOP - NodeID ulid.ULID - } - eventOP int -) +// Event is an event that occurs when a scheme.Spec is changed. +type Event struct { + OP eventOP + NodeID ulid.ULID +} + +type eventOP int const ( // EventInsert indicates an event for inserting a scheme.Spec. diff --git a/pkg/storage/stream.go b/pkg/storage/stream.go index 3f58aa7e..865fcdbd 100644 --- a/pkg/storage/stream.go +++ b/pkg/storage/stream.go @@ -6,14 +6,12 @@ import ( "github.com/siyul-park/uniflow/pkg/primitive" ) -type ( - // Stream is a stream to track scheme.Spec changes. - Stream struct { - stream database.Stream - channel chan Event - done chan struct{} - } -) +// Stream is a stream to track scheme.Spec changes. +type Stream struct { + stream database.Stream + channel chan Event + done chan struct{} +} // NewStream returns a new Stream. func NewStream(stream database.Stream) *Stream {