Skip to content

Commit

Permalink
refactor: consistence style (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park authored Dec 1, 2023
1 parent ccef4fa commit 34143d0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |

<!-- Go -->
Expand Down
2 changes: 1 addition & 1 deletion cmd/uniflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions pkg/scheme/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 7 additions & 8 deletions pkg/storage/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions pkg/storage/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 34143d0

Please sign in to comment.