model: split options, add logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0005f23585
commit
eb1b14da8a
@ -1,12 +1,6 @@
|
||||
// Package model is an interface for data modelling
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/unistack-org/micro/v3/codec"
|
||||
"github.com/unistack-org/micro/v3/store"
|
||||
"github.com/unistack-org/micro/v3/sync"
|
||||
)
|
||||
|
||||
// Model provides an interface for data modelling
|
||||
type Model interface {
|
||||
// Initialise options
|
||||
@ -37,24 +31,3 @@ type Entity interface {
|
||||
// Read a value as a concrete type
|
||||
Read(v interface{}) error
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
// Database to write to
|
||||
Database string
|
||||
// for serialising
|
||||
Codec codec.Marshaler
|
||||
// for locking
|
||||
Sync sync.Sync
|
||||
// for storage
|
||||
Store store.Store
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
type ReadOptions struct{}
|
||||
|
||||
type ReadOption func(o *ReadOptions)
|
||||
|
||||
type DeleteOptions struct{}
|
||||
|
||||
type DeleteOption func(o *DeleteOptions)
|
||||
|
39
model/options.go
Normal file
39
model/options.go
Normal file
@ -0,0 +1,39 @@
|
||||
// Package model is an interface for data modelling
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/unistack-org/micro/v3/codec"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
"github.com/unistack-org/micro/v3/store"
|
||||
"github.com/unistack-org/micro/v3/sync"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
// Database to write to
|
||||
Database string
|
||||
// for serialising
|
||||
Codec codec.Marshaler
|
||||
// for locking
|
||||
Sync sync.Sync
|
||||
// for storage
|
||||
Store store.Store
|
||||
// for logger
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
// Logger sets the logger
|
||||
func Logger(l logger.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = l
|
||||
}
|
||||
}
|
||||
|
||||
type ReadOptions struct{}
|
||||
|
||||
type ReadOption func(o *ReadOptions)
|
||||
|
||||
type DeleteOptions struct{}
|
||||
|
||||
type DeleteOption func(o *DeleteOptions)
|
Loading…
x
Reference in New Issue
Block a user