From eb1b14da8abba90a3d208b4d7dacd03503885688 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 29 Aug 2020 17:40:25 +0300 Subject: [PATCH] model: split options, add logger Signed-off-by: Vasiliy Tolstov --- model/model.go | 27 --------------------------- model/options.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 model/options.go diff --git a/model/model.go b/model/model.go index a6edbe9e..8f33912d 100644 --- a/model/model.go +++ b/model/model.go @@ -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) diff --git a/model/options.go b/model/options.go new file mode 100644 index 00000000..6e1284eb --- /dev/null +++ b/model/options.go @@ -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)