diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0ecb5c3
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ca6ea45
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/servicetmpl.iml b/.idea/servicetmpl.iml
new file mode 100644
index 0000000..dc8612b
--- /dev/null
+++ b/.idea/servicetmpl.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..6856299
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,740 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /serviceconfig
+ database
+ UserDataMysql
+ close
+ tran
+ trans
+ Richard
+
+
+ /servicetmpl
+ DBTranStore
+
+
+ C:\code\src\github.com\jfeng45\servicetmpl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ direct
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..c8d148a
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Jin Feng
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d482c00
--- /dev/null
+++ b/README.md
@@ -0,0 +1,122 @@
+# Service Template
+
+This is a project for me to figure out what is the best program layout for a business Microservice project in GRPC and Go. This is not the final version, which will supports transaction. Adding transaction will bring more complex into the project. In case there is no need for transaction, you can use it as the project template. It also doesn't expose the service through GRPC interface. For most people, I do recommend the full featured version [here](link).
+
+##How to use this project
+This project is best to be used as a starting point when creating a business gRPC Microservice project. It already has rich functionality to build in and is working, so there is no need to start from scratch. The purpose of it is not including many functions into it, but to build a flexible foundation, which can be extended easily. When I design and build the project, I followed SOLID design in object-oriented programing and Go's concise coding style, so it can be used as a living example of application design and coding style when you try to enforce it in your organization or your code. You may have different different design and coding style with what I have here, it is easy to change it to fit into your needs.
+
+## Use as a template to start a service project
+### Functional Feature:
+1. Support different implementation of database by changing configuration file ( Currently it supports MySQL and CouchDB) (The database can be SQL and NoSQL)
+2. Support different implementation of logging lib by changing configuration file ( Currently it supports ZAP and Logrus)( The logger lib need to support common interface similar to ZAP and Logrus)
+3. Support business level transaction inside a service without database transaction code in business layer( it doesn't suppose nested transaction or transaction across multiple Microservice)
+4. Using Dependency Injection to create concrete types and wire the whole application together.
+5. Application configurations are saved in yaml file and can be changed easily.
+
+### Design Feature:
+##### 1. Programming on interface
+Access outside functions through interface
+Has three layer: use case, model and persistence. Each layer access other layer through interface ( Except for model layer, which doesn't need interface)
+##### 2. Create concrete type through Dependency Inject by using factory method pattern
+##### 3. Minimize Dependency
+Dependency between different layers is only on interface ( except for model, which doesn't have interface)
+Interface is defined in top level package and separated from concrete type.
+Each concrete type is defined in a separate sub-package and file
+##### 4. Function Isolation
+Isolate different layer by package and file
+Isolate each use case by package
+Isolate each implementation ( for example database implementation) by package
+##### 5. Open-closed principle
+whenever a new feature is added, instead modify existing code, try to add new code
+
+
+### Coding Style:
+1. No use of package level variable except in "appcontainer" package
+2. Minimize use of constant
+Constants are read-only global variables, even though they are better than mutable ones, still should be restricted.
+Basically, functions should encapsulate itself.
+3. Log full stack trace for error
+4. Errors are only handled on top level ( All other levels should only add information and propagate error to upper level)
+5. separation of concerns
+business logic, functional requirements (For example, retry, timeout, transaction) and technical implementation ( for example, database, logger ) are different concerns and shouldn't be mixed in one piece of code.
+6. Naming Convention
+function or block level variable should be named according to Go's concise naming convention, but type or interfaces shouldn't. For them, readability overweight concise, you should tell what it for from it's name.
+
+## Getting Started
+
+### Installation and Setting Up
+
+Don't need to follow all steps in this section to get the code to work. The simplest way is to get the code from github and run it. However, it will throw exception when accesses database. So, I'd recommend you install at least one database ( MySQL is better), then most part of the code will work.
+
+#### Download Code
+
+```
+go get github.com/jfeng45/sericeconfig
+```
+
+#### Set Up MySQL
+
+There are two database implementations, MySQL and CouchDB, but most functions are implemented in MySQL. You'd better install at least one of them.
+```
+Install MySQL
+run SQL script in script folder to create database and table
+```
+#### Install CouchDB
+
+The code works fine without it. This part just shows the feature of switching database by changing configuration.
+
+Installation on [Windows](https://docs.couchdb.org/en/2.2.0/install/windows.html)
+
+Installation on [Linux](https://docs.couchdb.org/en/2.2.0/install/unix.html)
+
+Installation on [Mac](https://docs.couchdb.org/en/2.2.0/install/mac.html)
+
+CouchDB [Example](https://github.com/go-kivik/kivik/wiki/Usage-Examples)
+
+#### Set up CouchDB
+
+```
+Access Fauxton through broswer: http://localhost:5984/_utils/# (login with: admin/admin)
+Create new database "service_config" in Fauxton
+Add the following document to database ( "_id" and "_rev" are generated by database, no need to change it)
+{
+ "_id": "80a9134c7dfa53f67f6be214e1000fa7",
+ "_rev": "4-f45fb8bdd454a71e6ae88bdeea8a0b4c",
+ "uid": 10,
+ "username": "Tony",
+ "department": "IT",
+ "created": "2018-02-17T15:04:05-03:00"
+}
+```
+#### Install Cache Service (Another Microservice)
+
+Without it, only calling another Microservice piece won't work, the rest of code works just fine. Please follow instructions in [reservegrpc](https://github.com/jfeng45/reservegrpc) to set up the service.
+
+###S tart Application
+
+#### Start MySQL Server
+```
+cd [MySQLroot]/bin
+mysqld
+```
+
+#### Start CouchDB Server
+```
+It should already been started
+```
+#### Start Cache Service
+
+Please follow instructions in [reservegrpc](https://github.com/jfeng45/reservegrpc) to start the server.
+
+#### Run main
+In "main.go", under main() function, there are two functions "testMySql()" ( which reads configurations from "configs/appConifgDev.yaml") and "testCouchDB()" which reads from "configs/appConifgProd.yaml") to test MySQL and CouchDB separately.
+```
+cd [rootOfProject]/cmd
+go run main.go
+```
+## License
+
+[MIT](LICENSE.txt) License
+
+
+
diff --git a/adapter/cacheclient/cacheClient.go b/adapter/cacheclient/cacheClient.go
new file mode 100644
index 0000000..4a82043
--- /dev/null
+++ b/adapter/cacheclient/cacheClient.go
@@ -0,0 +1,46 @@
+// Package cacheclient is the wrapper around the thrid party gRPC Cache Microservice.
+// It encapsulates the logic to call outside service, to make it transparent to the business logic layer.
+
+package cacheclient
+
+import (
+ "context"
+ pb "github.com/jfeng45/servicetmpl/adapter/cacheclient/generatedclient"
+ "github.com/jfeng45/servicetmpl/tools"
+ "google.golang.org/grpc"
+)
+
+// CacheDataGrpc represents the gRPC connection handler
+type CacheDataGrpc struct {
+ Conn grpc.ClientConn
+}
+
+// getCacheClient creates a gRPC client
+func getCacheClient(conn grpc.ClientConn) pb.CacheServiceClient {
+ return pb.NewCacheServiceClient(&conn)
+}
+
+// Get handles call to Get function on Cache service
+func (cdg CacheDataGrpc) Get(key string) ([]byte, error) {
+ cacheClient := getCacheClient(cdg.Conn)
+ resp, err := cacheClient.Get(context.Background(), &pb.GetReq{Key: key})
+ if err != nil {
+ return nil, err
+ } else {
+ return resp.Value, err
+ }
+}
+
+// Store handles call to Store function on Cache service
+func (cdg CacheDataGrpc) Store(key string, value []byte) error {
+ cacheClient := getCacheClient(cdg.Conn)
+ ctx := context.Background()
+ _, err:= cacheClient.Store(ctx, &pb.StoreReq{Key:key,Value:value})
+
+ if err != nil {
+ return err
+ } else {
+ tools.Log.Debug("store called")
+ }
+ return nil
+}
diff --git a/adapter/cacheclient/generatedclient/cacheJin.pb.go b/adapter/cacheclient/generatedclient/cacheJin.pb.go
new file mode 100644
index 0000000..a9bbc3b
--- /dev/null
+++ b/adapter/cacheclient/generatedclient/cacheJin.pb.go
@@ -0,0 +1,449 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: cacheJin.proto
+
+package generatedclient
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+
+import (
+ context "golang.org/x/net/context"
+ grpc "google.golang.org/grpc"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type DumpReq struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *DumpReq) Reset() { *m = DumpReq{} }
+func (m *DumpReq) String() string { return proto.CompactTextString(m) }
+func (*DumpReq) ProtoMessage() {}
+func (*DumpReq) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{0}
+}
+func (m *DumpReq) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_DumpReq.Unmarshal(m, b)
+}
+func (m *DumpReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_DumpReq.Marshal(b, m, deterministic)
+}
+func (dst *DumpReq) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DumpReq.Merge(dst, src)
+}
+func (m *DumpReq) XXX_Size() int {
+ return xxx_messageInfo_DumpReq.Size(m)
+}
+func (m *DumpReq) XXX_DiscardUnknown() {
+ xxx_messageInfo_DumpReq.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_DumpReq proto.InternalMessageInfo
+
+type DumpItem struct {
+ Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ Val []byte `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *DumpItem) Reset() { *m = DumpItem{} }
+func (m *DumpItem) String() string { return proto.CompactTextString(m) }
+func (*DumpItem) ProtoMessage() {}
+func (*DumpItem) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{1}
+}
+func (m *DumpItem) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_DumpItem.Unmarshal(m, b)
+}
+func (m *DumpItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_DumpItem.Marshal(b, m, deterministic)
+}
+func (dst *DumpItem) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DumpItem.Merge(dst, src)
+}
+func (m *DumpItem) XXX_Size() int {
+ return xxx_messageInfo_DumpItem.Size(m)
+}
+func (m *DumpItem) XXX_DiscardUnknown() {
+ xxx_messageInfo_DumpItem.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_DumpItem proto.InternalMessageInfo
+
+func (m *DumpItem) GetKey() string {
+ if m != nil {
+ return m.Key
+ }
+ return ""
+}
+
+func (m *DumpItem) GetVal() []byte {
+ if m != nil {
+ return m.Val
+ }
+ return nil
+}
+
+type StoreReq struct {
+ Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *StoreReq) Reset() { *m = StoreReq{} }
+func (m *StoreReq) String() string { return proto.CompactTextString(m) }
+func (*StoreReq) ProtoMessage() {}
+func (*StoreReq) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{2}
+}
+func (m *StoreReq) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_StoreReq.Unmarshal(m, b)
+}
+func (m *StoreReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_StoreReq.Marshal(b, m, deterministic)
+}
+func (dst *StoreReq) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_StoreReq.Merge(dst, src)
+}
+func (m *StoreReq) XXX_Size() int {
+ return xxx_messageInfo_StoreReq.Size(m)
+}
+func (m *StoreReq) XXX_DiscardUnknown() {
+ xxx_messageInfo_StoreReq.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_StoreReq proto.InternalMessageInfo
+
+func (m *StoreReq) GetKey() string {
+ if m != nil {
+ return m.Key
+ }
+ return ""
+}
+
+func (m *StoreReq) GetValue() []byte {
+ if m != nil {
+ return m.Value
+ }
+ return nil
+}
+
+type StoreResp struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *StoreResp) Reset() { *m = StoreResp{} }
+func (m *StoreResp) String() string { return proto.CompactTextString(m) }
+func (*StoreResp) ProtoMessage() {}
+func (*StoreResp) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{3}
+}
+func (m *StoreResp) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_StoreResp.Unmarshal(m, b)
+}
+func (m *StoreResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_StoreResp.Marshal(b, m, deterministic)
+}
+func (dst *StoreResp) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_StoreResp.Merge(dst, src)
+}
+func (m *StoreResp) XXX_Size() int {
+ return xxx_messageInfo_StoreResp.Size(m)
+}
+func (m *StoreResp) XXX_DiscardUnknown() {
+ xxx_messageInfo_StoreResp.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_StoreResp proto.InternalMessageInfo
+
+type GetReq struct {
+ Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *GetReq) Reset() { *m = GetReq{} }
+func (m *GetReq) String() string { return proto.CompactTextString(m) }
+func (*GetReq) ProtoMessage() {}
+func (*GetReq) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{4}
+}
+func (m *GetReq) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_GetReq.Unmarshal(m, b)
+}
+func (m *GetReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_GetReq.Marshal(b, m, deterministic)
+}
+func (dst *GetReq) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_GetReq.Merge(dst, src)
+}
+func (m *GetReq) XXX_Size() int {
+ return xxx_messageInfo_GetReq.Size(m)
+}
+func (m *GetReq) XXX_DiscardUnknown() {
+ xxx_messageInfo_GetReq.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_GetReq proto.InternalMessageInfo
+
+func (m *GetReq) GetKey() string {
+ if m != nil {
+ return m.Key
+ }
+ return ""
+}
+
+type GetResp struct {
+ Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *GetResp) Reset() { *m = GetResp{} }
+func (m *GetResp) String() string { return proto.CompactTextString(m) }
+func (*GetResp) ProtoMessage() {}
+func (*GetResp) Descriptor() ([]byte, []int) {
+ return fileDescriptor_cacheJin_de21aa9a66397cc7, []int{5}
+}
+func (m *GetResp) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_GetResp.Unmarshal(m, b)
+}
+func (m *GetResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_GetResp.Marshal(b, m, deterministic)
+}
+func (dst *GetResp) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_GetResp.Merge(dst, src)
+}
+func (m *GetResp) XXX_Size() int {
+ return xxx_messageInfo_GetResp.Size(m)
+}
+func (m *GetResp) XXX_DiscardUnknown() {
+ xxx_messageInfo_GetResp.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_GetResp proto.InternalMessageInfo
+
+func (m *GetResp) GetValue() []byte {
+ if m != nil {
+ return m.Value
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*DumpReq)(nil), "reservegrpc.DumpReq")
+ proto.RegisterType((*DumpItem)(nil), "reservegrpc.DumpItem")
+ proto.RegisterType((*StoreReq)(nil), "reservegrpc.StoreReq")
+ proto.RegisterType((*StoreResp)(nil), "reservegrpc.StoreResp")
+ proto.RegisterType((*GetReq)(nil), "reservegrpc.GetReq")
+ proto.RegisterType((*GetResp)(nil), "reservegrpc.GetResp")
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConn
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion4
+
+// CacheServiceClient is the client API for CacheService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type CacheServiceClient interface {
+ Store(ctx context.Context, in *StoreReq, opts ...grpc.CallOption) (*StoreResp, error)
+ Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error)
+ Dump(ctx context.Context, in *DumpReq, opts ...grpc.CallOption) (CacheService_DumpClient, error)
+}
+
+type cacheServiceClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewCacheServiceClient(cc *grpc.ClientConn) CacheServiceClient {
+ return &cacheServiceClient{cc}
+}
+
+func (c *cacheServiceClient) Store(ctx context.Context, in *StoreReq, opts ...grpc.CallOption) (*StoreResp, error) {
+ out := new(StoreResp)
+ err := c.cc.Invoke(ctx, "/reservegrpc.CacheService/Store", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *cacheServiceClient) Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error) {
+ out := new(GetResp)
+ err := c.cc.Invoke(ctx, "/reservegrpc.CacheService/Get", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *cacheServiceClient) Dump(ctx context.Context, in *DumpReq, opts ...grpc.CallOption) (CacheService_DumpClient, error) {
+ stream, err := c.cc.NewStream(ctx, &_CacheService_serviceDesc.Streams[0], "/reservegrpc.CacheService/Dump", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &cacheServiceDumpClient{stream}
+ if err := x.ClientStream.SendMsg(in); err != nil {
+ return nil, err
+ }
+ if err := x.ClientStream.CloseSend(); err != nil {
+ return nil, err
+ }
+ return x, nil
+}
+
+type CacheService_DumpClient interface {
+ Recv() (*DumpItem, error)
+ grpc.ClientStream
+}
+
+type cacheServiceDumpClient struct {
+ grpc.ClientStream
+}
+
+func (x *cacheServiceDumpClient) Recv() (*DumpItem, error) {
+ m := new(DumpItem)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// CacheServiceServer is the server API for CacheService service.
+type CacheServiceServer interface {
+ Store(context.Context, *StoreReq) (*StoreResp, error)
+ Get(context.Context, *GetReq) (*GetResp, error)
+ Dump(*DumpReq, CacheService_DumpServer) error
+}
+
+func RegisterCacheServiceServer(s *grpc.Server, srv CacheServiceServer) {
+ s.RegisterService(&_CacheService_serviceDesc, srv)
+}
+
+func _CacheService_Store_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(StoreReq)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(CacheServiceServer).Store(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/reservegrpc.CacheService/Store",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(CacheServiceServer).Store(ctx, req.(*StoreReq))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _CacheService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetReq)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(CacheServiceServer).Get(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/reservegrpc.CacheService/Get",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(CacheServiceServer).Get(ctx, req.(*GetReq))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _CacheService_Dump_Handler(srv interface{}, stream grpc.ServerStream) error {
+ m := new(DumpReq)
+ if err := stream.RecvMsg(m); err != nil {
+ return err
+ }
+ return srv.(CacheServiceServer).Dump(m, &cacheServiceDumpServer{stream})
+}
+
+type CacheService_DumpServer interface {
+ Send(*DumpItem) error
+ grpc.ServerStream
+}
+
+type cacheServiceDumpServer struct {
+ grpc.ServerStream
+}
+
+func (x *cacheServiceDumpServer) Send(m *DumpItem) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+var _CacheService_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "reservegrpc.CacheService",
+ HandlerType: (*CacheServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "Store",
+ Handler: _CacheService_Store_Handler,
+ },
+ {
+ MethodName: "Get",
+ Handler: _CacheService_Get_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "Dump",
+ Handler: _CacheService_Dump_Handler,
+ ServerStreams: true,
+ },
+ },
+ Metadata: "cacheJin.proto",
+}
+
+func init() { proto.RegisterFile("cacheJin.proto", fileDescriptor_cacheJin_de21aa9a66397cc7) }
+
+var fileDescriptor_cacheJin_de21aa9a66397cc7 = []byte{
+ // 242 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x4d, 0x4b, 0x03, 0x31,
+ 0x10, 0x6d, 0xac, 0xfd, 0xd8, 0x69, 0x11, 0x89, 0xad, 0x94, 0x5c, 0x2c, 0x73, 0xea, 0x29, 0xc8,
+ 0x7a, 0xd0, 0xbb, 0x42, 0xd1, 0x63, 0xfa, 0x0b, 0xd6, 0x30, 0x68, 0xb1, 0x75, 0xd3, 0x24, 0x0d,
+ 0xf8, 0xc3, 0xfc, 0x7f, 0x92, 0x74, 0xa5, 0xbb, 0xec, 0xde, 0x5e, 0xde, 0xcc, 0x7b, 0xcc, 0x7b,
+ 0x81, 0x2b, 0x5d, 0xe8, 0x4f, 0x7a, 0xdb, 0x7e, 0x4b, 0x63, 0x4b, 0x5f, 0xf2, 0x89, 0x25, 0x47,
+ 0x36, 0xd0, 0x87, 0x35, 0x1a, 0x33, 0x18, 0xbd, 0x1c, 0xf7, 0x46, 0xd1, 0x01, 0x25, 0x8c, 0x23,
+ 0x7c, 0xf5, 0xb4, 0xe7, 0xd7, 0xd0, 0xff, 0xa2, 0x9f, 0x05, 0x5b, 0xb2, 0x55, 0xa6, 0x22, 0x8c,
+ 0x4c, 0x28, 0x76, 0x8b, 0x8b, 0x25, 0x5b, 0x4d, 0x55, 0x84, 0x98, 0xc3, 0x78, 0xe3, 0x4b, 0x4b,
+ 0x8a, 0x0e, 0x1d, 0xfb, 0x33, 0x18, 0x84, 0x62, 0x77, 0xa4, 0x4a, 0x71, 0x7a, 0xe0, 0x04, 0xb2,
+ 0x4a, 0xe3, 0x0c, 0x0a, 0x18, 0xae, 0xc9, 0x77, 0xca, 0xf1, 0x0e, 0x46, 0x69, 0xe6, 0xcc, 0xd9,
+ 0x89, 0xd5, 0x9c, 0xf2, 0x5f, 0x06, 0xd3, 0xe7, 0x18, 0x6c, 0x43, 0x36, 0x6c, 0x35, 0xf1, 0x27,
+ 0x18, 0x24, 0x6b, 0x3e, 0x97, 0xb5, 0x80, 0xf2, 0xff, 0x44, 0x71, 0xdb, 0x45, 0x3b, 0x83, 0x3d,
+ 0x9e, 0x43, 0x7f, 0x4d, 0x9e, 0xdf, 0x34, 0x16, 0x4e, 0x97, 0x89, 0x59, 0x9b, 0x4c, 0x9a, 0x47,
+ 0xb8, 0x8c, 0x65, 0xf1, 0xe6, 0xbc, 0xaa, 0x52, 0xcc, 0x5b, 0x6c, 0x6c, 0x15, 0x7b, 0xf7, 0xec,
+ 0x7d, 0x98, 0x3e, 0xe1, 0xe1, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x84, 0x90, 0x28, 0x3f, 0x96, 0x01,
+ 0x00, 0x00,
+}
diff --git a/adapter/cacheclient/generatedclient/doc.go b/adapter/cacheclient/generatedclient/doc.go
new file mode 100644
index 0000000..651de2a
--- /dev/null
+++ b/adapter/cacheclient/generatedclient/doc.go
@@ -0,0 +1,2 @@
+//Package generatedclient is created to save the generated client lib for gRPC call.
+package generatedclient
diff --git a/adapter/doc.go b/adapter/doc.go
new file mode 100644
index 0000000..5971689
--- /dev/null
+++ b/adapter/doc.go
@@ -0,0 +1,4 @@
+// Package adapter represents varies third part resource need to be accessed. Don't be confused with "tools" package,
+// which is for third part library, which is mainly for lower level library. "adapter" package, on the other hand,
+// which is mainly for data access on business layer
+package adapter
diff --git a/adapter/paymentclient/paymentClient.go b/adapter/paymentclient/paymentClient.go
new file mode 100644
index 0000000..3dc2583
--- /dev/null
+++ b/adapter/paymentclient/paymentClient.go
@@ -0,0 +1,2 @@
+// Package paymentclient is created to show the project structure, no real use.
+package paymentclient
diff --git a/appcontainer/appContainer.go b/appcontainer/appContainer.go
new file mode 100644
index 0000000..1081a6f
--- /dev/null
+++ b/appcontainer/appContainer.go
@@ -0,0 +1,51 @@
+//package appcontainer use dependency injection to create concrete type and wire the whole application together
+package appcontainer
+
+import (
+ logFactory "github.com/jfeng45/servicetmpl/appcontainer/loggerfactory"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/pkg/errors"
+)
+
+// InitApp loads the application configurations and logger
+func InitApp( factoryMap map[string]interface{},filename string ) error {
+ err := loadConfig(filename)
+ if err != nil {
+ return errors.Wrap(err,"loadConfig")
+ }
+ config := configs.GetAppConfig()
+
+ err = loadLogger(config.Log)
+ if err != nil {
+ return errors.Wrap(err,"loadLogger")
+ }
+ return nil
+}
+
+// loads the logger
+func loadLogger(lc configs.LogConfig) error {
+ loggerType :=lc.Code
+ err := logFactory.GetLogFactoryBuilder(loggerType).Build(&lc)
+ if err !=nil {
+ return errors.Wrap(err, "")
+ }
+ return nil
+}
+
+// loads the application configurations
+func loadConfig (filename string) error {
+
+ if !configs.GetReloadConfig() {
+ return nil
+ }
+ ac, err := configs.ReadConfig(filename)
+ if err != nil {
+ return errors.Wrap(err, "read appcontainer")
+ }
+ configs.SetAppConfig(&ac)
+ //set the flag to false, so won't reload it again
+ configs.SetReloadConfig(false)
+
+ return nil
+}
+
diff --git a/appcontainer/cacheFactory.go b/appcontainer/cacheFactory.go
new file mode 100644
index 0000000..48c82fe
--- /dev/null
+++ b/appcontainer/cacheFactory.go
@@ -0,0 +1,41 @@
+package appcontainer
+
+import (
+ "github.com/jfeng45/servicetmpl/adapter/cacheclient"
+ "github.com/jfeng45/servicetmpl/appcontainer/registry"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+ "google.golang.org/grpc"
+)
+
+// addCacheData creates CacheDataInterface
+func addCacheData(factoryMap map[string]interface{}, gc *configs.GrpcConfig) (dataservice.CacheDataInterface, error) {
+ conn, err := grpc.Dial(gc.Target, grpc.WithInsecure())
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+
+ cdg := cacheclient.CacheDataGrpc{*conn}
+ key := gc.Target
+ factoryMap[key] = &cdg
+ return &cdg, err
+}
+
+// retrieveCache retrieves CacheDataInterface from factory map. If it is not in map yet, it created one and put it
+// into map.
+// CacheDataInterface is a singleton
+func retrieveCache(factoryMap map[string]interface{}, gc *configs.GrpcConfig) (dataservice.CacheDataInterface, error){
+ key := gc.Code
+ value, found := registry.GetFromRegistry(factoryMap, key)
+ if found {
+ tools.Log.Debug("find RetrieveCache key=%v \n",key)
+ return value.(dataservice.CacheDataInterface), nil
+ }
+ //not in map, need to create one
+ tools.Log.Debug("doesn't find key=%v need to created a new one\n",key)
+ return addCacheData(factoryMap, gc)
+}
+
+
diff --git a/appcontainer/databasefactory/couchdbFactory.go b/appcontainer/databasefactory/couchdbFactory.go
new file mode 100644
index 0000000..aaec0dc
--- /dev/null
+++ b/appcontainer/databasefactory/couchdbFactory.go
@@ -0,0 +1,40 @@
+package databasefactory
+
+import (
+ "context"
+ couchdbKivid "github.com/go-kivik/couchdb"
+ "github.com/go-kivik/kivik"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+)
+
+// couchdbFactory is receiver for build method
+type couchdbFactory dbFactoryBuilder
+
+// implement build method for CouchDB database
+func (mf *couchdbFactory) build(factoryMap map[string]interface{}, dbc *configs.DatabaseConfig) (dataservice.UserDataInterface, error) {
+ tools.Log.Debug("couchdbFactory")
+
+ // Don't know why needs adding the following line, because the driver is already registered in init() in couchdbKiv
+ // however, not adding this, I got the error "unknown driver "couch" (forgotten import?)"
+ kivik.Register(COUCHDB, &couchdbKivid.Couch{})
+
+ key := dbc.Code
+ client, err := kivik.New(context.TODO(), dbc.Code, dbc.DataSourceName)
+
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ db, err := client.DB(context.TODO(), dbc.DbName)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ udc := couchdb.UserDataCouchdb{db}
+ tools.Log.Debugf("udc:%v",udc)
+ factoryMap[key] = &udc
+ return &udc, nil
+
+}
\ No newline at end of file
diff --git a/appcontainer/databasefactory/databaseFactory.go b/appcontainer/databasefactory/databaseFactory.go
new file mode 100644
index 0000000..1b27347
--- /dev/null
+++ b/appcontainer/databasefactory/databaseFactory.go
@@ -0,0 +1,57 @@
+// package databasefactory using factory method pattern to create concrete database handler
+package databasefactory
+
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer/registry"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/tools"
+)
+
+// Empty struct to server as a receiver for build method
+type dbFactoryBuilder struct {}
+
+// The builder interface for factory method pattern
+// Every factory needs to implement build method
+type dbFbInterface interface {
+ build(map[string]interface{}, *configs.DatabaseConfig) ( dataservice.UserDataInterface, error)
+}
+
+// database code. Need to map to the database code in the configuration yaml file.
+const (
+ MYSQL string ="mysql"
+ COUCHDB string ="couch"
+
+)
+
+// builder map to map database code to database interface builder
+// Concreate builder is in corresponding factory file. For example, "mysqlFactory" is in "mysqlFactory".go
+var dbFactoryBuilderMap = map[string]dbFbInterface {
+ MYSQL: &mysqlFactory{},
+ COUCHDB: &couchdbFactory{},
+}
+
+//GetDbFactoryBuilder is accessors for factoryBuilderMap
+func GetDbFactoryBuilder(key string) dbFbInterface {
+ return dbFactoryBuilderMap[key]
+}
+
+// RetrieveUserData retrieves the UserDataInterface from registry.
+// If UserDataInterface is not in registry, it will call corresponding builder factory to created UserDataInterface
+// based on database code
+func RetrieveUserData(factoryMap map[string]interface{}, dc *configs.DatabaseConfig, dfbi dbFbInterface) (dataservice.UserDataInterface, error){
+ key := dc.Code
+ tools.Log.Debug("RetrieveUserData: dbc.driverName=", key)
+ value, found := registry.GetFromRegistry(factoryMap, key)
+ if found {
+ tools.Log.Debug("found RetrieveListUser: key=", key)
+ return value.(dataservice.UserDataInterface), nil
+ }
+ // not in map, need to create one
+ tools.Log.Debugf("doesn't find key=%v need to craeted a new one\n", key)
+ return dfbi.build(factoryMap, dc)
+}
+
+
+
+
diff --git a/appcontainer/databasefactory/mysqlFactory.go b/appcontainer/databasefactory/mysqlFactory.go
new file mode 100644
index 0000000..0507add
--- /dev/null
+++ b/appcontainer/databasefactory/mysqlFactory.go
@@ -0,0 +1,37 @@
+package databasefactory
+
+import (
+ "database/sql"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/dataservice/gdbc"
+ "github.com/jfeng45/servicetmpl/dataservice/userdata/mysql"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+)
+
+// mysqlFactory is receiver for build method
+type mysqlFactory dbFactoryBuilder
+
+// implement build method for MySQL database
+func (mf *mysqlFactory) build(factoryMap map[string]interface{}, dc *configs.DatabaseConfig) (dataservice.UserDataInterface, error) {
+ tools.Log.Debug("mySqlFactory")
+ key := dc.Code
+ db, err := sql.Open(dc.DriverName, dc.DataSourceName)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ // check the connection
+ err =db.Ping()
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+
+ dt := gdbc.DBTx{DB: db}
+ uts := mysql.DBTxStore{DB: &dt}
+ tools.Log.Debug("uts", uts)
+ factoryMap[key] = &uts
+ return &uts, nil
+
+}
+
diff --git a/appcontainer/listUserFactory.go b/appcontainer/listUserFactory.go
new file mode 100644
index 0000000..c1720fa
--- /dev/null
+++ b/appcontainer/listUserFactory.go
@@ -0,0 +1,43 @@
+package appcontainer
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer/databasefactory"
+ "github.com/jfeng45/servicetmpl/appcontainer/registry"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/jfeng45/servicetmpl/usecase"
+ "github.com/jfeng45/servicetmpl/usecase/listuser"
+ "github.com/pkg/errors"
+)
+
+// listUserFactory creates ListUserUseCaseInterface
+func listUserFactory(factoryMap map[string]interface{}, appConfig *configs.AppConfig, key string) (usecase.ListUserUseCaseInterface, error) {
+
+ uc := &appConfig.UseCase.Registration.UserConfig
+ udi, err := databasefactory.RetrieveUserData(factoryMap, uc, databasefactory.GetDbFactoryBuilder(uc.Code))
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ cdi, err := retrieveCache(factoryMap, &appConfig.CacheGrpcConfig)
+ luuc := listuser.ListUserUseCase{UserDataInterface: udi, CacheDataInterface: cdi}
+
+ factoryMap[key] = &luuc
+
+ return &luuc, nil
+}
+
+// RetrieveListUser retrieves ListUserUseCaseInterface from factory map. If it is not in map yet, it created one and put it
+// into map.
+// RetrieveListUser is a singleton
+func RetrieveListUser(factoryMap map[string]interface{}) (usecase.ListUserUseCaseInterface, error){
+ config := configs.GetAppConfig()
+ key := config.UseCase.ListUser.Code
+ value, found := registry.GetFromRegistry(factoryMap, key)
+ if found {
+ tools.Log.Debug("found RetrieveListUser: key=", key)
+ return value.(usecase.ListUserUseCaseInterface), nil
+ }
+ //not in map, need to create one
+ tools.Log.Debugf("doesn't find key=%v need to created a new one\n",key)
+ return listUserFactory(factoryMap, config, key)
+}
+
diff --git a/appcontainer/loggerfactory/logFactory.go b/appcontainer/loggerfactory/logFactory.go
new file mode 100644
index 0000000..dbb783e
--- /dev/null
+++ b/appcontainer/loggerfactory/logFactory.go
@@ -0,0 +1,31 @@
+// package logger handles creating concrete logger with factory method pattern
+package logger
+
+import (
+ "github.com/jfeng45/servicetmpl/configs"
+)
+
+// empty type for logger receiver
+type logFactoryBuilder struct {}
+
+// interface for logger factory
+type logFbInterface interface {
+ Build(*configs.LogConfig) error
+}
+
+// constant for logger code, it needs to match code in configuration
+const (
+ LOGRUS string ="logrus"
+ ZAP string ="zap"
+
+)
+// logger mapp to map logger code to logger builder
+var logfactoryBuilderMap = map[string]logFbInterface{
+ ZAP: &zapFactory{},
+ LOGRUS: &logrusFactory{},
+}
+
+// accessors for factoryBuilderMap
+func GetLogFactoryBuilder(key string) logFbInterface {
+ return logfactoryBuilderMap[key]
+}
diff --git a/appcontainer/loggerfactory/logrus/logrus.go b/appcontainer/loggerfactory/logrus/logrus.go
new file mode 100644
index 0000000..e723e1e
--- /dev/null
+++ b/appcontainer/loggerfactory/logrus/logrus.go
@@ -0,0 +1,71 @@
+// package logrus handles creating logrus logger
+package logrus
+
+import (
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+ "os"
+)
+
+//type loggerWrapper struct {
+// lw *logrus.Logger
+//}
+//
+//func (logger *loggerWrapper) Errorf(format string, args ...interface{}) {
+// logger.lw.Errorf(format, args)
+//}
+//func (logger *loggerWrapper) Fatalf(format string, args ...interface{}) {
+// logger.lw.Fatalf(format, args)
+//}
+//func (logger *loggerWrapper) Fatal(args ...interface{}) {
+// logger.lw.Fatal(args)
+//}
+//func (logger *loggerWrapper) Infof(format string, args ...interface{}) {
+// logger.lw.Infof(format, args)
+//}
+//func (logger *loggerWrapper) Warnf(format string, args ...interface{}) {
+// logger.lw.Warnf(format, args)
+//}
+//func (logger *loggerWrapper) Debugf(format string, args ...interface{}) {
+// logger.lw.Debugf(format, args)
+//}
+//func (logger *loggerWrapper) Printf(format string, args ...interface{}) {
+// logger.lw.Printf(format, args)
+//}
+//func (logger *loggerWrapper) Println(args ...interface{}) {
+// logger.lw.Println(args)
+//}
+
+func RegisterLog(lc configs.LogConfig) error{
+ //standard configuration
+ log := logrus.New()
+ log.SetFormatter(&logrus.TextFormatter{})
+ log.SetReportCaller(true)
+ log.SetOutput(os.Stdout)
+ //customize it from configuration file
+ err := customizeLogFromConfig(log, lc)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ //This is for loggerWrapper implementation
+ //logger.Logger(&loggerWrapper{log})
+
+ tools.SetLogger(log)
+ return nil
+}
+
+// customizeLogFromConfig customize log based on parameters from configuration file
+func customizeLogFromConfig(log *logrus.Logger, lc configs.LogConfig) error{
+ log.SetReportCaller(lc.EnableCaller)
+ log.SetOutput(os.Stdout)
+ l := &log.Level
+ err := l.UnmarshalText([]byte(lc.Level))
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ log.SetLevel(*l)
+ return nil
+}
+
diff --git a/appcontainer/loggerfactory/logrusFactory.go b/appcontainer/loggerfactory/logrusFactory.go
new file mode 100644
index 0000000..4c69fc6
--- /dev/null
+++ b/appcontainer/loggerfactory/logrusFactory.go
@@ -0,0 +1,19 @@
+package logger
+
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer/loggerfactory/logrus"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/pkg/errors"
+)
+
+// receiver for logrus factory
+type logrusFactory logFactoryBuilder
+
+// build logrus logger
+func (mf *logrusFactory) Build(lc *configs.LogConfig) error {
+ err := logrus.RegisterLog(*lc)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ return nil
+}
diff --git a/appcontainer/loggerfactory/zap/zap.go b/appcontainer/loggerfactory/zap/zap.go
new file mode 100644
index 0000000..d4de261
--- /dev/null
+++ b/appcontainer/loggerfactory/zap/zap.go
@@ -0,0 +1,117 @@
+// package zap handles creating zap logger
+package zap
+
+import (
+ "encoding/json"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+ "go.uber.org/zap"
+)
+
+//type loggerWrapper struct {
+// lw *zap.SugaredLogger
+//}
+//
+
+//func (logger *loggerWrapper) Errorf(format string, args ...interface{}) {
+// logger.lw.Errorf(format, args)
+//}
+//func (logger *loggerWrapper) Fatalf(format string, args ...interface{}) {
+// logger.lw.Fatalf(format, args)
+//}
+//func (logger *loggerWrapper) Fatal(args ...interface{}) {
+// logger.lw.Fatal(args)
+//}
+//func (logger *loggerWrapper) Infof(format string, args ...interface{}) {
+// logger.lw.Infof(format, args)
+//}
+//func (logger *loggerWrapper) Warnf(format string, args ...interface{}) {
+// logger.lw.Warnf(format, args)
+//}
+//func (logger *loggerWrapper) Debugf(format string, args ...interface{}) {
+// logger.lw.Debugf(format, args)
+//}
+//func (logger *loggerWrapper) Printf(format string, args ...interface{}) {
+// logger.lw.Infof(format, args)
+//}
+//func (logger *loggerWrapper) Println(args ...interface{}) {
+// logger.lw.Info(args, "\n")
+//}
+
+func RegisterLog(lc configs.LogConfig) error{
+ zLogger, err:=initLog(lc)
+ if err!= nil {
+ return errors.Wrap(err, "RegisterLog")
+ }
+ defer zLogger.Sync()
+ zSugarlog := zLogger.Sugar()
+ zSugarlog.Info()
+
+ //This is for loggerWrapper implementation
+ //appLogger.SetLogger(&loggerWrapper{zaplog})
+
+ tools.SetLogger(zSugarlog)
+ return nil
+}
+
+// initLog create logger
+func initLog (lc configs.LogConfig) (zap.Logger, error){
+ rawJSON := []byte(`{
+ "level": "info",
+ "Development": true,
+ "DisableCaller": false,
+ "encoding": "console",
+ "outputPaths": ["stdout", "./demo.log"],
+ "errorOutputPaths": ["stderr"],
+ "encoderConfig": {
+ "timeKey": "ts",
+ "levelKey": "level",
+ "messageKey": "msg",
+ "nameKey": "name",
+ "stacktraceKey": "stacktrace",
+ "callerKey": "caller",
+ "lineEnding": "\n\t",
+ "timeEncoder": "time",
+ "levelEncoder": "lowercaseLevel",
+ "durationEncoder": "stringDuration",
+ "callerEncoder": "shortCaller"
+ }
+ }`)
+
+ var cfg zap.Config
+ var zLogger *zap.Logger
+ //standard configuration
+ if err := json.Unmarshal(rawJSON, &cfg); err != nil {
+ return *zLogger, errors.Wrap(err, "Unmarshal")
+ }
+ //customize it from configuration file
+ err := customizeLogFromConfig(&cfg, lc)
+ if err != nil {
+ return *zLogger, errors.Wrap(err, "cfg.Build()")
+ }
+ zLogger, err = cfg.Build()
+ if err != nil {
+ return *zLogger, errors.Wrap(err, "cfg.Build()")
+ }
+
+ zLogger.Debug("logger construction succeeded")
+ return *zLogger, nil
+}
+
+// customizeLogFromConfig customize log based on parameters from configuration file
+func customizeLogFromConfig(cfg *zap.Config, lc configs.LogConfig) error{
+ cfg.DisableCaller =!lc.EnableCaller
+
+ // set log level
+ l := zap.NewAtomicLevel().Level()
+ err :=l.Set(lc.Level)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ cfg.Level.SetLevel(l)
+
+ return nil
+}
+
+
diff --git a/appcontainer/loggerfactory/zapFactory.go b/appcontainer/loggerfactory/zapFactory.go
new file mode 100644
index 0000000..b38a62f
--- /dev/null
+++ b/appcontainer/loggerfactory/zapFactory.go
@@ -0,0 +1,20 @@
+package logger
+
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer/loggerfactory/zap"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/pkg/errors"
+)
+
+// receiver for logrus factory
+type zapFactory logFactoryBuilder
+
+// build zap logger
+func (mf *zapFactory) Build(lc *configs.LogConfig) error {
+
+ err := zap.RegisterLog(*lc)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ return nil
+}
diff --git a/appcontainer/registrationFactory.go b/appcontainer/registrationFactory.go
new file mode 100644
index 0000000..fecf1ce
--- /dev/null
+++ b/appcontainer/registrationFactory.go
@@ -0,0 +1,43 @@
+package appcontainer
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer/databasefactory"
+ "github.com/jfeng45/servicetmpl/appcontainer/registry"
+ "github.com/jfeng45/servicetmpl/configs"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/jfeng45/servicetmpl/usecase"
+ "github.com/jfeng45/servicetmpl/usecase/registration"
+ "github.com/pkg/errors"
+)
+
+// addRegistration creates RegistrationUseCaseInterface
+func addRegistration(factoryMap map[string]interface{}, appConfig *configs.AppConfig, key string) (usecase.RegistrationUseCaseInterface, error) {
+
+ uc := &appConfig.UseCase.Registration.UserConfig
+ udi, err := databasefactory.RetrieveUserData(factoryMap, uc, databasefactory.GetDbFactoryBuilder(uc.Code))
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ ruc := registration.RegistrationUseCase{UserDataInterface: udi}
+
+ factoryMap[key] = &ruc
+
+ return &ruc, nil
+}
+
+// RetrieveRegistration retrieves RegistrationUseCaseInterface from factory map. If it is not in map yet, it created one and put it
+// into map.
+// RetrieveRegistration is a singleton
+func RetrieveRegistration(factoryMap map[string]interface{}) (usecase.RegistrationUseCaseInterface, error){
+ config := configs.GetAppConfig()
+ key := config.UseCase.Registration.Code
+ value, found := registry.GetFromRegistry(factoryMap, key)
+ if found {
+ tools.Log.Debug("found Retrieve registration: key=", key)
+ return value.(usecase.RegistrationUseCaseInterface), nil
+ }
+ //not in map, need to create one
+ tools.Log.Debugf("doesn't find key=%v need to created a new one\n",key)
+ return addRegistration(factoryMap, config, key)
+}
+
+
diff --git a/appcontainer/registry/registry.go b/appcontainer/registry/registry.go
new file mode 100644
index 0000000..b947e37
--- /dev/null
+++ b/appcontainer/registry/registry.go
@@ -0,0 +1,16 @@
+// package registry represents application configuration registry, so the configuration is loaded only once
+package registry
+
+import (
+ "github.com/jfeng45/servicetmpl/tools"
+)
+
+// GetFromRegistry get configuration from registry based on key
+func GetFromRegistry(factoryMap map[string]interface{}, key string) (interface{}, bool) {
+
+ tools.Log.Debug("getFromRegistry: key=", key)
+ luc1, found := factoryMap[key]
+ return luc1, found
+
+}
+
diff --git a/cmd/demo.log b/cmd/demo.log
new file mode 100644
index 0000000..6656d19
--- /dev/null
+++ b/cmd/demo.log
@@ -0,0 +1,2305 @@
+1.5617052774274104e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617052774284081e+09 info zap/zap.go:48
+ 1.5617052774328992e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617052774333982e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617052774343975e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561705277437391e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617052774393883e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617052774403882e+09 debug databasefactory/mysqlFactory.go:14 mySqlFactory
+ 1.5617052777553005e+09 debug databasefactory/mysqlFactory.go:27 udm{0xc0000b4300}
+ 1.5617052777572966e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617052777587988e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617052777617881e+09 debug userdata/userDataService.go:111 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.561705277762287e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617052777632854e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561705277763785e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5617052790648677e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:129
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5617052790658634e+09 info cmd/main.go:133 find user:
+ 1.5617053257973793e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617053257983775e+09 info zap/zap.go:48
+ 1.561705325799875e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617053258013737e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617053258018708e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=couch
+ 1.561705325802869e+09 debug registry/registry.go:7 getFromRegistry: key=couch
+ 1.5617053258038685e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=couch need to craeted a new one
+
+ 1.5617053258048654e+09 debug databasefactory/couchdbFactory.go:16 couchdbFactory
+ 1.561705326430702e+09 debug databasefactory/couchdbFactory.go:33 udc:{0xc000140510}
+ 1.5617053264341958e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617053264346952e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617053278750165e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:129
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:23
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:13
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5617053278854973e+09 error couchdb/couchdb.go:30 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/couchdb.go:30
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/couchdb.go:38
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:29
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:129
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:23
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:13
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5617053278864949e+09 debug couchdb/couchdb.go:32 rev:
+ 1.5617053279034638e+09 debug couchdb/couchdb.go:51 view:{Id:10 Name:Tony Department:IT Created:2018-02-17 15:04:05 -0300 -0300}
+ 1.5617053279034638e+09 info cmd/main.go:133 find user:&{10 Tony IT 2018-02-17 15:04:05 -0300 -0300}
+ 1.5617633418287714e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561763341830268e+09 info zap/zap.go:48
+ 1.5617633418367555e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617633418372548e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617633418417678e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617633418427444e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617633418447483e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617633418457386e+09 debug databasefactory/mysqlFactory.go:14 mySqlFactory
+ 1.5617633421786199e+09 debug databasefactory/mysqlFactory.go:27 udm{0xc0000b4300}
+ 1.5617633421786199e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.561763342181616e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617633421881027e+09 debug userdata/userDataService.go:111 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617633421886015e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617633421930954e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617633421950896e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5617633434939046e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:129
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5617633435048838e+09 info cmd/main.go:133 find user:
+ 1.5617867857379708e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617867857394686e+09 info zap/zap.go:48
+ 1.5617867857409658e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617867857419639e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617867857429643e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617867857434607e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617867857439632e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561786785744958e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617867860618691e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015c010}
+ 1.5617867860618691e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617867860648668e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.561786786069355e+09 debug userdata/userDataService.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617867860698543e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617874337690349e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617874337715302e+09 info zap/zap.go:48
+ 1.5617874337745247e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617874337745247e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617874337755227e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617874337760217e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617874337770205e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617874337780192e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617874340944297e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000142010}
+ 1.5617874340949314e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617874340984476e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617874341019173e+09 debug userdata/userDataService.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617874341024153e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.561789133230798e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617891332322958e+09 info zap/zap.go:48
+ 1.561789133234293e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561789133234293e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617891332352908e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617891332357893e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617891332367887e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617891332372878e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617891335546987e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006020}
+ 1.5617891335551953e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617891335576906e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617891335621824e+09 debug mysql/userDataService.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617891335621824e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617891941799028e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617891941809006e+09 info zap/zap.go:48
+ 1.5617891941864116e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617891941868925e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617891941873882e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617891941883876e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617891941923795e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617891941943753e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617891945067973e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006020}
+ 1.5617891945072935e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617891945092928e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617891945137818e+09 debug mysql/userDataMysql.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617891945137818e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617892551435206e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617892551465144e+09 info zap/zap.go:48
+ 1.5617892551500268e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617892551505044e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617892551510034e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561789255152004e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561789255152504e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561789255157991e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617892554714093e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901c0}
+ 1.5617892554714093e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617892554739058e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617892554788952e+09 debug mysql/userDataMysql.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617892554793932e+09 info cmd/main.go:101 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617894972899966e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617894972924917e+09 info zap/zap.go:48
+ 1.5617894972949872e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561789497295986e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617894972969835e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617894972984807e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617894972984807e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617894972995024e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561789497619384e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.561789497619384e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617894976208825e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617894976243753e+09 debug mysql/userDataMysql.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617894976248744e+09 info cmd/main.go:103 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617897377953732e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617897377958724e+09 info zap/zap.go:48
+ 1.5617897377988677e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5617897377988677e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5617897377998667e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561789737800366e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561789737801364e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617897378018613e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561789738113347e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.5617897381138463e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5617897381163418e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5617897381223333e+09 debug mysql/userDataMysql.go:115 find user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617897381228302e+09 info cmd/main.go:103 user list:[{2 Aditi Marketing 2019-06-01 00:00:00 +0000 UTC} {3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5617902225810056e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617902225825083e+09 info zap/zap.go:48
+ 1.5617902225845e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617902225849981e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617902225854971e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617902225864952e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617902225869944e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617902225874934e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617902229009106e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00016a008}
+ 1.561790222917879e+09 debug mysql/userDataMysql.go:132 update: rows affected: 1
+ 1.56179040423363e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617904042346287e+09 info zap/zap.go:48
+ 1.5617904042381434e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617904042381434e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617904042391198e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617904042396219e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617904042401206e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561790404241116e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617904045540342e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000170008}
+ 1.5617904045565324e+09 debug mysql/userDataMysql.go:132 update: rows affected: 0
+ 1.56179040455703e+09 info cmd/main.go:138 ModifyAndUnregister succeed
+ 1.5617910114244852e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617910114259822e+09 info zap/zap.go:48
+ 1.561791011427979e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561791011427979e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617910114289765e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561791011429479e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617910114304755e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617910114314759e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617910117443922e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000174008}
+ 1.5617910117468858e+09 debug mysql/userDataMysql.go:132 update: rows affected: 0
+ 1.561791011747385e+09 info cmd/main.go:138 ModifyAndUnregister succeed
+ 1.5617911868810482e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617911868825467e+09 info zap/zap.go:48
+ 1.5617911868850434e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617911868860385e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617911868870363e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561791186887536e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617911868885336e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617911868895323e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617911872083607e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.5617911872093542e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5617911872173407e+09 debug transaction/transaction.go:102 transaction end
+ 1.5617911875301979e+09 debug mysql/userDataMysql.go:132 update: rows affected: 0
+ 1.5617911875316942e+09 debug transaction/transaction.go:120 error returned from txFuc():: rows affected is 0
+ 1.5617911875376909e+09 debug transaction/transaction.go:112 found error and rollback:: rows affected is 0
+ 1.5617911875421746e+09 info cmd/main.go:157 ModifyAndUnregisterWithTx succeed
+ 1.5617933497642062e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617933497657e+09 info zap/zap.go:48
+ 1.5617933497692149e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617933497692149e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617933497701936e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561793349770691e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.56179334977119e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617933497721877e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617933500866034e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.5617933500925932e+09 debug mysql/userDataMysql.go:131 update: rows affected: 1
+ 1.5617933500930936e+09 info cmd/main.go:140 ModifyAndUnregister succeed
+ 1.5617934181499083e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617934181519063e+09 info zap/zap.go:48
+ 1.5617934181548994e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617934181553996e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617934181563964e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617934181568983e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561793418157896e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617934181583953e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617934184718099e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b0}
+ 1.5617934184728112e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.5617934184743054e+09 info cmd/main.go:140 ModifyAndUnregister succeed
+ 1.5617935615406063e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617935615421023e+09 info zap/zap.go:48
+ 1.5617935615475929e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617935615475929e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617935615485902e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617935615495882e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617935615505862e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617935615555794e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561793561867996e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.561793561869993e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.5617935618719893e+09 info cmd/main.go:140 ModifyAndUnregister succeed
+ 1.5617936964321299e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617936964326284e+09 info zap/zap.go:48
+ 1.561793696436124e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617936964366236e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617936964371204e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617936964376192e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617936964386177e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617936964396155e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617936967530332e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006018}
+ 1.5617936967565277e+09 debug mysql/userDataMysql.go:131 update: rows affected: 1
+ 1.5617936967580237e+09 debug mysql/userDataMysql.go:23 in remove
+ 1.56179369676102e+09 debug mysql/userDataMysql.go:42 remove:row affected 1
+ 1.56179369676152e+09 info cmd/main.go:140 ModifyAndUnregister succeed
+ 1.561799436841232e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617994368427308e+09 info zap/zap.go:48
+ 1.5617994368457258e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617994368462238e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617994368477209e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617994368487198e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617994368497167e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617994368537092e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617994371671264e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.5617994371676257e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5617994371701212e+09 debug transaction/transaction.go:102 transaction end
+ 1.5617994371900837e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.5617994371910849e+09 debug transaction/transaction.go:120 error returned from txFuc():: rows affected is 0
+ 1.561799437198069e+09 debug transaction/transaction.go:112 found error and rollback:: rows affected is 0
+ 1.561799437199067e+09 info cmd/main.go:158 ModifyAndUnregisterWithTx succeed
+ 1.561799717205051e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617997172060487e+09 info zap/zap.go:48
+ 1.561799717211041e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617997172115383e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617997172120397e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561799717213037e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561799717213537e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561799717214535e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617997175334647e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000176008}
+ 1.5617997175334647e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5617997175369594e+09 debug transaction/transaction.go:102 transaction end
+ 1.5617997175379572e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.5617997175384552e+09 debug transaction/transaction.go:120 error returned from txFuc():: rows affected is 0
+ 1.561799717539454e+09 debug transaction/transaction.go:112 found error and rollback:rows affected is 0
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).Update
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:136
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:51
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:53
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+ 1.5617997175439453e+09 info cmd/main.go:158 ModifyAndUnregisterWithTx succeed
+ 1.5617997919832523e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617997919847593e+09 info zap/zap.go:48
+ 1.5617997919862435e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617997919877405e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617997919887455e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617997919892552e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617997919902382e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561799791991254e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561799792305961e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5617997923069532e+09 debug transaction/transaction.go:63 transaction begin
+ 1.561799792314947e+09 debug transaction/transaction.go:102 transaction end
+ 1.561799792322932e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.5617997923279154e+09 debug transaction/transaction.go:120 error returned from txFuc():: rows affected is 0
+ 1.5617997923304112e+09 debug transaction/transaction.go:112 found error and rollback:%!(EXTRA *errors.withStack=: rows affected is 0)
+ 1.561799792331409e+09 info cmd/main.go:158 ModifyAndUnregisterWithTx succeed
+ 1.5617999476134288e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617999476139264e+09 info zap/zap.go:48
+ 1.5617999476164227e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617999476164227e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.56179994761742e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617999476189177e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617999476199157e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617999476239083e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617999479370167e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000142010}
+ 1.5617999479370167e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5617999479400156e+09 debug transaction/transaction.go:102 transaction end
+ 1.5617999479435103e+09 debug mysql/userDataMysql.go:131 update: rows affected: 0
+ 1.561799947944004e+09 debug transaction/transaction.go:120 error returned from txFuc():: rows affected is 0
+ 1.5617999479445033e+09 debug transaction/transaction.go:112 found error and rollback:%!(EXTRA *errors.withStack=: rows affected is 0)
+ 1.5617999479455028e+09 error cmd/main.go:156 ModifyAndUnregisterWithTx failed:rows affected is 0
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).Update
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:136
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:51
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:53
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:156
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5617999870759075e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5617999870764067e+09 info zap/zap.go:48
+ 1.5617999870799212e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5617999870799212e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5617999870799212e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5617999870799212e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5617999870804014e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5617999870804014e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5617999873948176e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006018}
+ 1.5617999873958073e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5617999873973188e+09 debug transaction/transaction.go:102 transaction end
+ 1.561799987400299e+09 debug mysql/userDataMysql.go:131 update: rows affected: 1
+ 1.56179998740131e+09 debug transaction/transaction.go:120 error returned from txFuc():: : Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete1 from userinfo where uid=?' at line 1
+ 1.5617999874092886e+09 debug transaction/transaction.go:112 found error and rollback:%!(EXTRA *errors.withStack=: : Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete1 from userinfo where uid=?' at line 1)
+ 1.561799987426753e+09 error cmd/main.go:156 ModifyAndUnregisterWithTx failed:Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete1 from userinfo where uid=?' at line 1
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).Remove
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:28
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:55
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:57
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:74
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:119
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:225
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:72
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:156
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618001400090828e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618001400095842e+09 info zap/zap.go:48
+ 1.561800140013078e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618001400135767e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618001400145757e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618001400150735e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618001400160794e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618001400165865e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561800140329061e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5618001403295603e+09 debug transaction/transaction.go:63 transaction begin
+ 1.5618001403330543e+09 debug mysql/userDataMysql.go:131 update: rows affected: 1
+ 1.561800140334551e+09 debug mysql/userDataMysql.go:42 remove:row affected 1
+ 1.5618001403350492e+09 debug transaction/transaction.go:113 commit:
+ 1.561800140337045e+09 info cmd/main.go:158 ModifyAndUnregisterWithTx succeed
+ 1.5618528403311734e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618528403321729e+09 info zap/zap.go:48
+ 1.56185284033417e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.56185284033417e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.56185284033417e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.56185284033417e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.56185284033417e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.56185284033417e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618528406529891e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006018}
+ 1.5618528406529891e+09 debug transaction/transaction.go:58 transaction begin
+ 1.5618528406620028e+09 debug mysql/userDataMysql.go:126 update: rows affected: 0
+ 1.5618528406620028e+09 debug transaction/transaction.go:102 found error and rollback:%!(EXTRA *errors.withStack=: rows affected is 0)
+ 1.5618528406620028e+09 error cmd/main.go:156 ModifyAndUnregisterWithTx failed:rows affected is 0
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).Update
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:131
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:158
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:158
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:154
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:156
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618546018484719e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618546018494716e+09 info zap/zap.go:48
+ 1.56185460185247e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.56185460185247e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561854601853469e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618546018544688e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618546018554695e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618546018564672e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618546021682925e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015c010}
+ 1.5618546021782835e+09 debug mysql/userDataMysql.go:151 user inserted:&{1 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618546021792843e+09 info cmd/main.go:73 new user registered:&{1 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618546471614797e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618546471624703e+09 info zap/zap.go:48
+ 1.5618546471644704e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618546471644704e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618546471654713e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618546471654713e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618546471664703e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618546471674674e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618546474782903e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00016a008}
+ 1.5618546474792886e+09 error cmd/main.go:72 user registration failed:duplicate user for Richard
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).RegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:20
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:70
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:72
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618546837304873e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561854683731489e+09 info zap/zap.go:48
+ 1.5618546837344844e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618546837344844e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561854683735484e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561854683736483e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561854683736483e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618546837374825e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618546840493052e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5618550590657074e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618550590667052e+09 info zap/zap.go:48
+ 1.5618550590697033e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618550590697033e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618550590707023e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618550590707023e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561855059071702e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618550590727038e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618550593835227e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.5618550593845224e+09 debug mysql/userDataMysql.go:37 remove:row affected 0
+ 1.561855059386521e+09 fatal cmd/main.go:55 testUnregister failed:UnregisterUser failed. No such user Peter
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).UnregisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:47
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:53
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:55
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618551454183843e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618551454193838e+09 info zap/zap.go:48
+ 1.561855145422383e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561855145422383e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618551454234025e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561855145424384e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561855145425402e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618551454263804e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618551457422006e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000160008}
+ 1.5618551457442005e+09 debug mysql/userDataMysql.go:37 remove:row affected 0
+ 1.5618551457502034e+09 fatal cmd/main.go:55 testUnregister failed:UnregisterUser failed. No such user Richard
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).UnregisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:47
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:53
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:55
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618557751776333e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561855775178632e+09 info zap/zap.go:48
+ 1.5618557751806307e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618557751816325e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618557751826296e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561855775183629e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561855775183629e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618557751846285e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.56185577549645e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5618557755004473e+09 debug mysql/userDataMysql.go:151 user inserted:&{2 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618557755004473e+09 info cmd/main.go:74 new user registered:&{2 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618557903899038e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561855790391902e+09 info zap/zap.go:48
+ 1.561855790392902e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618557903939013e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618557903939013e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618557903949003e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618557903959002e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618557903959002e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618557907087207e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901c0}
+ 1.5618557907097201e+09 debug mysql/userDataMysql.go:36 remove:row affected 0
+ 1.5618557907117188e+09 fatal cmd/main.go:55 testUnregister failed:UnregisterUser failed. No such user Richard
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).UnregisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:47
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:53
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:55
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:38
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618560127618673e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618560127628644e+09 info zap/zap.go:48
+ 1.561856012764863e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561856012765862e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561856012765862e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618560127668622e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618560127678607e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618560127678607e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561856013081685e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006020}
+ 1.561856013083681e+09 debug mysql/userDataMysql.go:36 remove:row affected 1
+ 1.5618560130846794e+09 info cmd/main.go:57 testUnregister successully
+ 1.5618645260494215e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618645260504215e+09 info zap/zap.go:48
+ 1.561864526053418e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561864526053418e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5618645260544178e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561864526055417e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561864526056417e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618645260574164e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618645263692389e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000160010}
+ 1.5618645263702357e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5618645263722346e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5618645263832316e+09 debug mysql/userDataMysql.go:110 find user list:[]
+ 1.5618645263832316e+09 info cmd/main.go:105 user list:[]
+ 1.561864526384228e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5618645263862312e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5618645277074893e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618645277084677e+09 info cmd/main.go:173 find user:
+ 1.5618645831266696e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5618645831276712e+09 info zap/zap.go:48
+ 1.561864583129672e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5618645831306689e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5618645831316657e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5618645831326683e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618645831326683e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618645831336672e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618645834454858e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5618645834494867e+09 debug mysql/userDataMysql.go:154 user inserted:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618645834494867e+09 info cmd/main.go:74 new user registered:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.561864622540053e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561864622541074e+09 info zap/zap.go:48
+ 1.56186462254405e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.56186462254405e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.561864622545051e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561864622545051e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5618646225460513e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5618646225470512e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5618646228588698e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5618646228588698e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5618646228608694e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5618646228658657e+09 debug mysql/userDataMysql.go:110 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5618646228658657e+09 info cmd/main.go:105 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5618646228658657e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5618646228668652e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5618646241701384e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5618646241731157e+09 debug mysql/userDataMysql.go:62 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5618646241761374e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.561938985404738e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561938985405739e+09 info zap/zap.go:48
+ 1.5619389854077363e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619389854077363e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619389854087353e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561938985409737e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561938985409737e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619389854157312e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619389857295542e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000170008}
+ 1.561938985730551e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.561938985732552e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.561938985737547e+09 debug mysql/userDataMysql.go:109 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.561938985737547e+09 info cmd/main.go:105 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.561938985738546e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561938985738546e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.561938987200709e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619389872117038e+09 debug mysql/userDataMysql.go:61 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619389872117038e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619399269774532e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561939926978452e+09 info zap/zap.go:48
+ 1.5619399269804494e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619399269814503e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619399269824483e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561939926983449e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561939926983449e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619399269844472e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561939927298269e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000164008}
+ 1.561939927298269e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5619399273002682e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619399273072624e+09 debug mysql/userDataMysql.go:109 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619399273072624e+09 info cmd/main.go:105 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619399273082619e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619399273112621e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5619399288004057e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619399288014052e+09 debug mysql/userDataMysql.go:61 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619399288084006e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619401060634632e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619401060654607e+09 info zap/zap.go:48
+ 1.5619401060674603e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619401060684607e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619401060684607e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619401060694597e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619401060704591e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561940106071458e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561940106383279e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.561940106383279e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5619401063852818e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619401063912745e+09 debug mysql/userDataMysql.go:109 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619401063912745e+09 info cmd/main.go:105 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.561940106392274e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561940106393276e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5619401078004668e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.561940107801465e+09 debug mysql/userDataMysql.go:61 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619401078074644e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619401837089088e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619401837089088e+09 info zap/zap.go:48
+ 1.5619401837099082e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619401837099082e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619401837099082e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619401837109084e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619401837109084e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619401837109084e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619401840217292e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015a010}
+ 1.5619401840227287e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5619401840227287e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619401840247276e+09 debug mysql/userDataMysql.go:109 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619401840247276e+09 info cmd/main.go:105 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619401840257275e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619401840257275e+09 debug appcontainer/listUserFactory.go:32 found RetrieveListUser: key=listUser
+ 1.5619401853289807e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619401853299806e+09 debug mysql/userDataMysql.go:61 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619401853329785e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619432171557255e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619432171577234e+09 info zap/zap.go:48
+ 1.5619432171587238e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619432171597266e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619432171607246e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561943217161724e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619432171627235e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619432171637235e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561943217479539e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000170008}
+ 1.561943217480538e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5619432174825368e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619432189147186e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619432189237127e+09 debug mysql/userDataMysql.go:68 rows to User:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619432189247096e+09 info cmd/main.go:173 find user:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619432370952833e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561943237097282e+09 info zap/zap.go:48
+ 1.561943237100284e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.561943237100284e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.5619432371012805e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.56194323710228e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619432371032798e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619432371042786e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619432374160986e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00016a008}
+ 1.5619432374171023e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.5619432374190974e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619432387263684e+09 error listuser/listUser.go:22 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:22
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:169
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:35
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619432387273493e+09 info cmd/main.go:173 find user:
+ 1.561951287002405e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561951287004402e+09 info zap/zap.go:48
+ 1.5619512870074008e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619512870074008e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619512870083983e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619512870094016e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561951287010397e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619512870113983e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619512873242164e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000166008}
+ 1.561951287334214e+09 debug mysql/userDataMysql.go:68 rows to User:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.561951287334214e+09 error cmd/main.go:72 user registration failed:duplicate user for Richard
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).RegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:20
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:70
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:72
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.56195152009565e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619515200986483e+09 info zap/zap.go:48
+ 1.5619515201006472e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619515201006472e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619515201016462e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561951520102646e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619515201036448e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619515201046443e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619515204214625e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015c008}
+ 1.5619515204264622e+09 debug mysql/userDataMysql.go:145 user inserted:&{4 Tony IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619515204264622e+09 info cmd/main.go:75 new user registered:&{4 Tony IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619516271042492e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619516271052496e+09 info zap/zap.go:48
+ 1.561951627106247e+09 debug registry/registry.go:7 getFromRegistry: key=listUser
+ 1.5619516271072466e+09 debug appcontainer/listUserFactory.go:36 doesn't find key=listUser need to created a new one
+
+ 1.561951627108245e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619516271092472e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619516271102455e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619516271112428e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619516274240632e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006020}
+ 1.5619516274240632e+09 debug registry/registry.go:7 getFromRegistry: key=cache
+ 1.561951627428063e+09 debug appcontainer/cacheFactory.go:34 doesn't find key=%v need to created a new one
+cache
+ 1.5619516274320586e+09 debug mysql/userDataMysql.go:68 rows to User:&{3 Richard finance 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619516274330585e+09 debug mysql/userDataMysql.go:68 rows to User:&{4 Tony IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.56195162743406e+09 debug mysql/userDataMysql.go:103 find user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC} {4 Tony IT 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619516274350657e+09 info cmd/main.go:106 user list:[{3 Richard finance 2018-12-09 00:00:00 +0000 UTC} {4 Tony IT 2018-12-09 00:00:00 +0000 UTC}]
+ 1.5619661017238162e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619661017248154e+09 info zap/zap.go:48
+ 1.5619661017278137e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561966101728814e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619661017298152e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619661017308145e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619661017318132e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619661017318132e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619661020516303e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b0}
+ 1.5619661020516303e+09 error cmd/main.go:75 user registration failed:created: cannot be blank; username: cannot be blank.
+
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).RegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:17
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:73
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:75
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619661636452851e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561966163646286e+09 info zap/zap.go:48
+ 1.5619661636503017e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619661636503017e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619661636512833e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619661636522827e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.56196616365328e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.56196616365328e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619661639661016e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.5619661639661016e+09 error cmd/main.go:75 user registration failed:created: cannot be blank; username: cannot be blank.
+user validation failed
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).RegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:17
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:73
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:75
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619710125041304e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561971012505129e+09 info zap/zap.go:48
+ 1.5619710125081267e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619710125081267e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619710125101256e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561971012511125e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561971012511125e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619710125121243e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619710128279436e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.5619710128419359e+09 debug mysql/userDataMysql.go:68 rows to User:&{4 Tony IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.561971012843936e+09 error cmd/main.go:76 user registration failed:duplicate user for Tony
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).RegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:24
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:74
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testRegisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:76
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:36
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.561971046264757e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619710462657583e+09 info zap/zap.go:48
+ 1.5619710462677557e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619710462687547e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619710462687547e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561971046269757e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561971046270756e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619710462717547e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619710465835738e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006018}
+ 1.5619710465885713e+09 debug mysql/userDataMysql.go:145 user inserted:&{5 Anshu IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.5619710465885713e+09 info cmd/main.go:79 new user registered:&{5 Anshu IT 2018-12-09 00:00:00 +0000 UTC}
+ 1.561971135847354e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619711358483555e+09 info zap/zap.go:48
+ 1.561971135850353e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619711358513508e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561971135852351e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.56197113585335e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619711358543491e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561971135855349e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619711361661696e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006018}
+ 1.561971136167171e+09 info cmd/main.go:96 Modify user failed:uid: cannot be blank.
+user validation failed
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:42
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:36
+main.testModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:94
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:37
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+ 1.5619711361711698e+09 info cmd/main.go:98 user modified:{0 Brian HR 2019-12-01 00:00:00 +0000 UTC}
+ 1.5619711802960768e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561971180297075e+09 info zap/zap.go:48
+ 1.5619711802990758e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619711803000898e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619711803010926e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619711803020747e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619711803030715e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619711803040705e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561971180617893e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015c010}
+ 1.561971180618891e+09 info cmd/main.go:96 Modify user failed:username: cannot be blank.
+user validation failed
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:42
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:36
+main.testModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:94
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:37
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+ 1.561971180620891e+09 info cmd/main.go:98 user modified:{1 HR 2019-12-01 00:00:00 +0000 UTC}
+ 1.5619711973213775e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619711973223758e+09 info zap/zap.go:48
+ 1.5619711973243752e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619711973253865e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561971197326394e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619711973273942e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619711973283722e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619711973283722e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619711976421933e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.5619711976441941e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619711976481898e+09 info cmd/main.go:98 user modified:{1 Brian HR 2019-12-01 00:00:00 +0000 UTC}
+ 1.5619713950756133e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619713950765903e+09 info zap/zap.go:48
+ 1.5619713950795894e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619713950805886e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619713950815883e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619713950815883e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561971395082588e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619713950835907e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619713953994088e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000006020}
+ 1.5619713954024146e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619713954064105e+09 info cmd/main.go:96 Modify user failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:36
+main.testModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:94
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:37
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+ 1.5619713954074023e+09 info cmd/main.go:98 user modified:{1 Brian HR 2019-12-01 00:00:00 +0000 UTC}
+ 1.5619714758454547e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619714758464527e+09 info zap/zap.go:48
+ 1.5619714758494523e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619714758494523e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619714758504503e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619714758504503e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619714758514495e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561971475852449e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619714761692705e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015e010}
+ 1.5619714761742668e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619714761762645e+09 info cmd/main.go:96 Modify user failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:36
+main.testModifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:94
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:37
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+ 1.561971512588482e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561971512589479e+09 info zap/zap.go:48
+ 1.5619715125914803e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619715125925066e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561971512593478e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619715125944757e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561971512595475e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561971512595475e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619715129082966e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b0}
+ 1.5619715129122934e+09 debug mysql/userDataMysql.go:124 update: rows affected: 1
+ 1.5619715129142928e+09 info cmd/main.go:98 user modified succeed:{3 Brian HR 2019-12-01 00:00:00 +0000 UTC}
+ 1.5619716815317814e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619716815337803e+09 info zap/zap.go:48
+ 1.5619716815367804e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619716815377777e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619716815377777e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561971681538779e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619716815397778e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619716815407772e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619716818525965e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000144010}
+ 1.5619716818525965e+09 info cmd/main.go:148 ModifyAndUnregister succeed
+ 1.5619720894733498e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619720894743488e+09 info zap/zap.go:48
+ 1.5619720894763482e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561972089477347e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619720894783466e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619720894793456e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619720894793456e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619720894803452e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.561972089794167e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015e008}
+ 1.5619720897951646e+09 debug registration/registraton.go:93 modifyAndUnregister
+ 1.5619720897971654e+09 debug registration/registraton.go:41 modifyAndUnregister
+ 1.5619720898001616e+09 info cmd/main.go:148 ModifyAndUnregister succeed
+ 1.561972156364966e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561972156364966e+09 info zap/zap.go:48
+ 1.5619721563679645e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561972156368964e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561972156369963e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561972156369963e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619721563709621e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619721563719625e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619721566837823e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.5619721566837823e+09 debug registration/registraton.go:93 modifyAndUnregister
+ 1.561972156686784e+09 debug registration/registraton.go:41 modifyUser
+ 1.561972156688782e+09 error cmd/main.go:146 ModifyAndUnregister failed:uid: cannot be blank.
+user validation failed
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:44
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:94
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:107
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:96
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:107
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:146
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619722475156653e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619722475156653e+09 info zap/zap.go:48
+ 1.5619722475166612e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619722475166612e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619722475176606e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619722475176606e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619722475176606e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619722475176606e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619722478304825e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000174008}
+ 1.5619722478324814e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.561972247833482e+09 error cmd/main.go:146 ModifyAndUnregister failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:50
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:93
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:95
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:146
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619722945946484e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619722945956502e+09 info zap/zap.go:48
+ 1.5619722945986474e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619722945996454e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619722945996454e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561972294600645e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561972294601648e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619722946026459e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619722949164631e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000144010}
+ 1.561972294920463e+09 debug mysql/userDataMysql.go:124 update: rows affected: 1
+ 1.561972294922462e+09 debug mysql/userDataMysql.go:36 remove:row affected 2
+ 1.561972294922462e+09 error cmd/main.go:146 ModifyAndUnregister failed:UnregisterUser failed. Number of users unregistered are 2
+github.com/jfeng45/servicetmpl/usecase/registration.unregisterUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:83
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:97
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:99
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:146
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619723563342206e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619723563352203e+09 info zap/zap.go:48
+ 1.561972356336221e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.561972356337221e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.561972356337221e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.561972356337221e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561972356337221e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619723563392184e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619723566540377e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901c0}
+ 1.5619723566560383e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619723566580367e+09 error cmd/main.go:146 ModifyAndUnregister failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:50
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:93
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:95
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:106
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:146
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5619734862821393e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5619734862841425e+09 info zap/zap.go:48
+ 1.5619734862861369e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619734862861369e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619734862871382e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619734862881377e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619734862891364e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619734862891364e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619734866039565e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000178008}
+ 1.5619734866049538e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619734866069546e+09 error cmd/main.go:146 ModifyAndUnregister failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:21
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:54
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:54
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:144
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:146
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.561973599656555e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561973599656555e+09 info zap/zap.go:48
+ 1.5619735996606078e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619735996615577e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619735996625516e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619735996635504e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.5619735996645525e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5619735996695476e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5619735999813724e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc00015c010}
+ 1.561973599988366e+09 debug mysql/userDataMysql.go:124 update: rows affected: 1
+ 1.5619735999913762e+09 debug mysql/userDataMysql.go:36 remove:row affected 1
+ 1.561973599992378e+09 info cmd/main.go:148 ModifyAndUnregister succeed
+ 1.5619834956457553e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.561983495647761e+09 info zap/zap.go:48
+ 1.5619834956497536e+09 debug registry/registry.go:7 getFromRegistry: key=registration
+ 1.5619834956507537e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5619834956507537e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5619834956517527e+09 debug registry/registry.go:7 getFromRegistry: key=mysql
+ 1.561983495652752e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.561983495653751e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.56198349596857e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158008}
+ 1.5619834959695706e+09 debug transaction/transaction.go:58 transaction begin
+ 1.5619834959735677e+09 debug mysql/userDataMysql.go:124 update: rows affected: 0
+ 1.5619834959745717e+09 debug transaction/transaction.go:102 found error and rollback:%!(EXTRA *errors.withStack=: Modify user failed. rows affected is 0)
+ 1.5619834959755666e+09 error cmd/main.go:164 ModifyAndUnregisterWithTx failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:21
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:64
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:150
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:62
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:162
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:64
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:150
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:62
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:162
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:164
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:41
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.562021509858908e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620215098599048e+09 info zap/zap.go:48
+ 1.562021509861904e+09 debug registry/registry.go:9 getFromRegistry: key=registration
+ 1.562021509861904e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5620215098629038e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5620215098639026e+09 debug registry/registry.go:9 getFromRegistry: key=mysql
+ 1.5620215098649006e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5620215098659012e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5620215101857152e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000168008}
+ 1.5620215101857152e+09 debug transaction/transaction.go:58 transaction begin
+ 1.5620215101987083e+09 debug mysql/userDataMysql.go:123 update: rows affected: 0
+ 1.5620215101987083e+09 debug transaction/transaction.go:102 found error and rollback:%!(EXTRA *errors.withStack=: Modify user failed. rows affected is 0)
+ 1.5620215101997101e+09 error cmd/main.go:163 ModifyAndUnregisterWithTx failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:21
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:66
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:149
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:64
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:66
+github.com/jfeng45/servicetmpl/dataservice/transaction.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/transaction/transaction.go:109
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:149
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:64
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:163
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620450249885454e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620450249885454e+09 info zap/zap.go:48
+ 1.5620450249905457e+09 debug registry/registry.go:9 getFromRegistry: key=registration
+ 1.5620450249905457e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.562045024992544e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.562045024992544e+09 debug registry/registry.go:9 getFromRegistry: key=mysql
+ 1.5620450249935434e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.5620450249945424e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5620450253193576e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc0000901b8}
+ 1.562045025335347e+09 debug mysql/userDataMysql.go:125 update: rows affected: 0
+ 1.562045025336346e+09 debug gdbc/transaction.go:54 found error and rollback:%!(EXTRA *errors.withStack=: Modify user failed. rows affected is 0)
+ 1.5620450253383448e+09 error cmd/main.go:163 ModifyAndUnregisterWithTx failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:21
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/gdbc.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/gdbc/transaction.go:61
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:151
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/gdbc.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/gdbc/transaction.go:61
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:151
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:163
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.562047968969197e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620479689701962e+09 info zap/zap.go:48
+ 1.5620479689731946e+09 debug registry/registry.go:9 getFromRegistry: key=registration
+ 1.5620479689741943e+09 debug appcontainer/registrationFactory.go:35 doesn't find key=registration need to created a new one
+
+ 1.5620479689781919e+09 debug databasefactory/databaseFactory.go:31 RetrieveUserData: dbc.driverName=mysql
+ 1.5620479689781919e+09 debug registry/registry.go:9 getFromRegistry: key=mysql
+ 1.5620479689801905e+09 debug databasefactory/databaseFactory.go:38 doesn't find key=mysql need to craeted a new one
+
+ 1.56204796898219e+09 debug databasefactory/mysqlFactory.go:15 mySqlFactory
+ 1.5620479693050053e+09 debug databasefactory/mysqlFactory.go:29 uts{0xc000158010}
+ 1.5620479693110023e+09 debug mysql/userDataMysql.go:125 update: rows affected: 0
+ 1.5620479693110023e+09 debug gdbc/transaction.go:54 found error and rollback:%!(EXTRA *errors.withStack=: Modify user failed. rows affected is 0)
+ 1.5620479693120005e+09 error cmd/main.go:163 ModifyAndUnregisterWithTx failed:Modify user failed. rows affected is 0
+github.com/jfeng45/servicetmpl/usecase/registration.modifyUser
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:21
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:47
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/gdbc.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/gdbc/transaction.go:61
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:151
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+github.com/jfeng45/servicetmpl/usecase/registration.modifyAndUnregister
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registrationHelper.go:49
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx.func1
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:70
+github.com/jfeng45/servicetmpl/dataservice/gdbc.(*ConnTx).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/gdbc/transaction.go:61
+github.com/jfeng45/servicetmpl/dataservice/userdata/mysql.(*DBTxStore).TxEnd
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/mysql/userDataMysql.go:151
+github.com/jfeng45/servicetmpl/usecase/registration.(*RegistrationUseCase).ModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/registration/registraton.go:68
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:161
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testModifyAndUnregisterWithTx
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:163
+main.testMySql
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:40
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:11
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620511338755996e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620511338765972e+09 info zap/zap.go:48
+ 1.562051133877598e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.562051133878596e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.562051133878596e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620511338795967e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.5620511338815954e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.5620511338835957e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620511348110616e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc0001b4450}
+ 1.5620511348110616e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.5620511348140597e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620511361243093e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620511361812763e+09 error couchdb/userDataCouchdb.go:32 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:32
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:40
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620511361812763e+09 debug couchdb/userDataCouchdb.go:34 rev:
+ 1.5620511364241354e+09 debug couchdb/userDataCouchdb.go:53 view:{Id:0 Name: Department: Created:0001-01-01 00:00:00 +0000 UTC}
+ 1.5620511364261353e+09 info cmd/main.go:179 find user:&{0 0001-01-01 00:00:00 +0000 UTC}
+ 1.5620517098590925e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.562051709860092e+09 info zap/zap.go:48
+ 1.5620517098700864e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.5620517098710842e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.562051709872085e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620517098740869e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.562051709875082e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.562051709875082e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620517105107188e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc000140750}
+ 1.5620517105107188e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.5620517105137165e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620517118229651e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620517118369577e+09 error couchdb/userDataCouchdb.go:32 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:32
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:40
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620517118409548e+09 debug couchdb/userDataCouchdb.go:34 rev:
+ 1.562051711906917e+09 debug couchdb/userDataCouchdb.go:53 view:{Id:12 Name:Kit Department:Engineering Created:2016-11-05 15:04:05 -0300 -0300}
+ 1.5620517119079168e+09 info cmd/main.go:179 find user:&{12 Kit Engineering 2016-11-05 15:04:05 -0300 -0300}
+ 1.5620519243230305e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620519243230305e+09 info zap/zap.go:48
+ 1.5620519243280263e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.5620519243290262e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.5620519243300254e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620519243310254e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.5620519243360217e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.562051924337021e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620519249596646e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc00014a570}
+ 1.562051924961665e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.562051924964661e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620519264108334e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620519264198272e+09 error couchdb/userDataCouchdb.go:32 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:32
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:40
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:175
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620519264198272e+09 debug couchdb/userDataCouchdb.go:34 rev:
+ 1.5620519264468126e+09 debug couchdb/userDataCouchdb.go:53 view:{Id:12 Name:Kit Department:Engineering Created:2016-11-05 15:04:05 -0300 -0300}
+ 1.5620519264468126e+09 info cmd/main.go:179 find user:&{12 Kit Engineering 2016-11-05 15:04:05 -0300 -0300}
+ 1.5620522394102328e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.562052239413227e+09 info zap/zap.go:48
+ 1.5620522394162254e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.5620522394162254e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.5620522394172268e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620522394182267e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.562052239419223e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.5620522394202244e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620522400478654e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc000106f00}
+ 1.5620522400478654e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.5620522400508623e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620522413631089e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.562052241372103e+09 error couchdb/userDataCouchdb.go:33 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:33
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:41
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620522413731031e+09 debug couchdb/userDataCouchdb.go:35 rev:
+ 1.5620522413880932e+09 debug couchdb/userDataCouchdb.go:54 view:
+ 1.5620522413890958e+09 info cmd/main.go:180 find user:
+ 1.5620522601023552e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620522601033542e+09 info zap/zap.go:48
+ 1.5620522601053534e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.5620522601063573e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.5620522601073523e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620522601083522e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.5620522601083522e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.562052260109351e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620522607299955e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc0001821b0}
+ 1.5620522607309976e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.5620522607329931e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620522620412426e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620522620462399e+09 error couchdb/userDataCouchdb.go:33 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:33
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:41
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620522620482416e+09 debug couchdb/userDataCouchdb.go:35 rev:
+ 1.5620522620532358e+09 error cmd/main.go:178 fin user failed failed:json: Unmarshal(nil *model.User)
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:51
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+runtime.goexit
+ C:/app1/Go/src/runtime/asm_amd64.s:1337
+
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:178
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620522620532358e+09 info cmd/main.go:180 find user:
+ 1.5620524796933503e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620524796933503e+09 info zap/zap.go:48
+ 1.5620524796953518e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.5620524796973493e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.5620524796973493e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620524796983478e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.5620524796983478e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.5620524796983478e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.5620524803559718e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc00014a750}
+ 1.5620524803559718e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.56205248035797e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.562052481672217e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620524816822095e+09 error couchdb/userDataCouchdb.go:33 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:33
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:41
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.562052481683209e+09 debug couchdb/userDataCouchdb.go:35 rev:
+ 1.5620524817121935e+09 debug couchdb/userDataCouchdb.go:55 view:&{Id:12 Name:Kit Department:Engineering Created:2016-11-05 15:04:05 -0300 -0300}
+ 1.562052481713196e+09 info cmd/main.go:180 find user:&{12 Kit Engineering 2016-11-05 15:04:05 -0300 -0300}
+ 1.5620524974131851e+09 debug zap/zap.go:96 logger construction succeeded
+ 1.5620524974141831e+09 info zap/zap.go:48
+ 1.562052497416181e+09 debug registry/registry.go:11 getFromRegistry: key=listUser
+ 1.562052497416181e+09 debug appcontainer/listUserFactory.go:40 doesn't find key=listUser need to created a new one
+
+ 1.562052497417183e+09 debug databasefactory/databaseFactory.go:44 RetrieveUserData: dbc.driverName=couch
+ 1.5620524974181821e+09 debug registry/registry.go:11 getFromRegistry: key=couch
+ 1.5620524974181821e+09 debug databasefactory/databaseFactory.go:51 doesn't find key=couch need to craeted a new one
+
+ 1.5620524974191804e+09 debug databasefactory/couchdbFactory.go:19 couchdbFactory
+ 1.562052498042822e+09 debug databasefactory/couchdbFactory.go:37 udc:{0xc000188360}
+ 1.562052498042822e+09 debug registry/registry.go:11 getFromRegistry: key=cache
+ 1.5620524980478187e+09 debug appcontainer/cacheFactory.go:37 doesn't find key=%v need to created a new one
+cache
+ 1.5620524993570695e+09 error listuser/listUser.go:28 get from cache error:%!(EXTRA *errors.withStack=: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:5051: connectex: No connection could be made because the target machine actively refused it.")
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:28
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620524993620653e+09 error couchdb/userDataCouchdb.go:33 err:Conflict: Document update conflict.
+
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.createView
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:33
+github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb.(*UserDataCouchdb).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/dataservice/userdata/couchdb/userDataCouchdb.go:41
+github.com/jfeng45/servicetmpl/usecase/listuser.(*ListUserUseCase).Find
+ C:/code/src/github.com/jfeng45/servicetmpl/usecase/listuser/listUser.go:35
+main.testFindById
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:176
+main.testCouchDB
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:22
+main.main
+ C:/code/src/github.com/jfeng45/servicetmpl/cmd/main.go:12
+runtime.main
+ C:/app1/Go/src/runtime/proc.go:200
+ 1.5620524993630655e+09 debug couchdb/userDataCouchdb.go:35 rev:
+ 1.562052499368061e+09 debug couchdb/userDataCouchdb.go:55 view:
+ 1.5620524993690612e+09 info cmd/main.go:180 find user:
+
\ No newline at end of file
diff --git a/cmd/main.go b/cmd/main.go
new file mode 100644
index 0000000..76f9976
--- /dev/null
+++ b/cmd/main.go
@@ -0,0 +1,181 @@
+package main
+
+import (
+ "github.com/jfeng45/servicetmpl/appcontainer"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/jfeng45/servicetmpl/tools"
+ "time"
+)
+
+func main() {
+ //testMySql()
+ testCouchDB()
+}
+func testCouchDB() {
+ factoryMap :=make(map[string]interface{})
+
+ filename := "../configs/appConfigProd.yaml"
+ err:= appcontainer.InitApp(factoryMap, filename)
+ if err!=nil {
+ tools.Log.Errorf("%+v\n", err)
+ }
+ testFindById(factoryMap)
+}
+func testMySql() {
+ factoryMap :=make(map[string]interface{})
+
+ filename := "../configs/appConfigDev.yaml"
+ err:= appcontainer.InitApp(factoryMap, filename)
+ if err!=nil {
+ tools.Log.Errorf("%+v\n", err)
+ }
+
+ //testListUser(factoryMap)
+ //testFindById(factoryMap)
+ //testRegisterUser(factoryMap)
+ //testModifyUser(factoryMap)
+ //testUnregister(factoryMap)
+
+ //testModifyAndUnregister(factoryMap)
+ testModifyAndUnregisterWithTx(factoryMap)
+ //testTransaction(factoryMap)
+
+}
+func testUnregister(factoryMap map[string]interface{}) {
+
+ ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("registration interface build failed:%+v\n", err)
+ }
+ username := "Richard"
+ //username := "Peter"
+ err =ruci.UnregisterUser(username)
+ if err != nil {
+ tools.Log.Fatalf("testUnregister failed:%+v\n", err)
+ }
+ tools.Log.Infof("testUnregister successully")
+}
+
+func testRegisterUser(factoryMap map[string]interface{}) {
+ ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("registration interface build failed:%+v\n", err)
+ }
+ created, err := time.Parse(tools.FORMAT_ISO8601_DATE,"2018-12-09")
+ if err != nil {
+ tools.Log.Errorf("date format err:%+v\n", err)
+ }
+ //user := usermodel.User{Name: "Richard", Department:"finance", Created:created}
+ //user := usermodel.User{Name: "Tony", Department:"IT", Created:created}
+ user := model.User{Name: "Anshu", Department:"IT", Created:created}
+ //created = time.Time{}
+ //user := usermodel.User{Name: "", Department:"IT", Created:created}
+
+ resultUser, err :=ruci.RegisterUser(&user)
+ if err != nil {
+ tools.Log.Errorf("user registration failed:%+v\n", err)
+ } else {
+ tools.Log.Info("new user registered:", resultUser)
+ }
+}
+
+func testModifyUser(factoryMap map[string]interface{}) {
+ ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("registration interface build failed:%+v\n", err)
+ }
+ created, err := time.Parse(tools.FORMAT_ISO8601_DATE,"2019-12-01")
+ if err != nil {
+ tools.Log.Errorf("date format err:%+v\n", err)
+ }
+ user := model.User{Id: 3, Name:"Brian", Department:"HR", Created:created}
+ //user := usermodel.User{Name:"Brian", Department:"HR", Created:created}
+ err =ruci.ModifyUser(&user)
+ if err !=nil {
+ tools.Log.Infof("Modify user failed:%+v\n", err)
+ } else {
+ tools.Log.Info("user modified succeed:", user)
+ }
+}
+
+func testListUser(factoryMap map[string]interface{}) {
+ rluf, err := appcontainer.RetrieveListUser(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("RetrieveListUser interface build failed:", err)
+ }
+ users, err := rluf.ListUser()
+ if err != nil {
+ tools.Log.Errorf("user list failed:%+v\n", err)
+ }
+ tools.Log.Info("user list:", users)
+}
+
+//func testTransaction(factoryMap map[string]interface{}) {
+// ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+// if err != nil {
+// logger.Log.Fatal("RegisterRegistration interface build failed:%+v\n", err)
+// }
+// created, err := time.Parse(timea.FORMAT_ISO8601_DATE,"2018-12-09")
+// if err != nil {
+// logger.Log.Errorf("date format err:%+v\n", err)
+// }
+// user :=model.User{Name:"Anshu", Department:"Sales", Created:created}
+// ruci.Transaction(&user)
+// if err != nil {
+// logger.Log.Errorf("transaction failed:%+v\n", err)
+// } else {
+// logger.Log.Infof("transaction succeed")
+// }
+//}
+
+func testModifyAndUnregister(factoryMap map[string]interface{}) {
+ ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("RegisterRegistration interface build failed:%+v\n", err)
+ }
+ created, err := time.Parse(tools.FORMAT_ISO8601_DATE,"2018-12-09")
+ if err != nil {
+ tools.Log.Errorf("date format err:%+v\n", err)
+ }
+ //user := usermodel.User{Name:"Anshu", Department:"Sales", Created:created}
+ user := model.User{Id: 4, Name:"Peter", Department:"Sales", Created:created}
+ //user :=model.User{Id:2, Name:"Aditi", Department:"Marketing", Created:created}
+ err = ruci.ModifyAndUnregister(&user)
+ if err != nil {
+ tools.Log.Errorf("ModifyAndUnregister failed:%+v\n", err)
+ } else {
+ tools.Log.Infof("ModifyAndUnregister succeed")
+ }
+}
+
+func testModifyAndUnregisterWithTx(factoryMap map[string]interface{}) {
+ ruci, err := appcontainer.RetrieveRegistration(factoryMap)
+ if err != nil {
+ tools.Log.Fatal("RegisterRegistration interface build failed:%+v\n", err)
+ }
+ created, err := time.Parse(tools.FORMAT_ISO8601_DATE,"2018-12-09")
+ if err != nil {
+ tools.Log.Errorf("date format err:%+v\n", err)
+ }
+ user := model.User{Id: 3, Name:"Anshu", Department:"Sales", Created:created}
+ err = ruci.ModifyAndUnregisterWithTx(&user)
+ if err != nil {
+ tools.Log.Errorf("ModifyAndUnregisterWithTx failed:%+v\n", err)
+ } else {
+ tools.Log.Infof("ModifyAndUnregisterWithTx succeed")
+ }
+}
+
+func testFindById(factoryMap map[string]interface{}) {
+ //It is uid in database. Make sure you have it in database, otherwise it won't find it.
+ id :=12
+ rluf, err := appcontainer.RetrieveListUser(factoryMap)
+ if err != nil {
+ tools.Log.Fatalf("RetrieveListUser interface build failed:%+v\n", err)
+ }
+ user, err := rluf.Find(id)
+ if err != nil {
+ tools.Log.Errorf("fin user failed failed:%+v\n", err)
+ }
+ tools.Log.Info("find user:", user)
+}
diff --git a/configs/appConfig.go b/configs/appConfig.go
new file mode 100644
index 0000000..6dc0c37
--- /dev/null
+++ b/configs/appConfig.go
@@ -0,0 +1,110 @@
+// Package config read configurations from a YAML file and load them into a AppConfig type to save the configuration
+// information for the application. The configuration information is loaded only once by a control flag.
+// configuration for different environment can be saved in files with different suffix, for example [Dev], [Prod]
+package configs
+
+import (
+ "fmt"
+ "github.com/pkg/errors"
+ "gopkg.in/yaml.v2"
+ "io/ioutil"
+)
+
+// AppConfig represents the application config
+type AppConfig struct {
+ MySQLConfig DatabaseConfig `yaml:"mySQLConfig"`
+ CouchdbConfig DatabaseConfig `yaml:"couchdbConfig"`
+ CacheGrpcConfig GrpcConfig `yaml:"cacheGrpcConfig"`
+ ZapConfig LogConfig `yaml:"zapConfig"`
+ LorusConfig LogConfig `yaml:"logrusConfig"`
+ Log LogConfig `yaml:"logConfig"`
+ UseCase UseCaseConfig `yaml:"useCaseConfig"`
+}
+
+// UseCaseConfig represents different use case
+type UseCaseConfig struct {
+ Registration RegistrationConfig `yaml:"registration"`
+ ListUser ListUserConfig `yaml:"listUser"`
+}
+
+// UseCaseConfig represents registration use case
+type RegistrationConfig struct {
+ Code string `yaml:"code"`
+ UserConfig DatabaseConfig `yaml:"userConfig"`
+}
+
+// UseCaseConfig represents list user use case
+type ListUserConfig struct {
+ Code string `yaml:"code"`
+ UserConfig DatabaseConfig `yaml:"userConfig"`
+ CacheConfig GrpcConfig `yaml:"cacheConfig"`
+}
+
+// DatabaseConfig represents database handler
+type DatabaseConfig struct{
+ Code string `yaml:"code"`
+ DriverName string `yaml:"driverName"`
+ DataSourceName string `yaml:"dataSourceName"`
+ DbName string `yaml:"dbName"`
+}
+
+// DatabaseConfig represents gRPC handler
+type GrpcConfig struct{
+ Code string `yaml:"code"`
+ GrpcName string `yaml:"grpcName"`
+ Target string `yaml:"target"`
+}
+
+// LogConfig represents logger handler
+// Logger has many parameters can be set or changed. Currently, only three are listed here, which is most likely to be
+// changed at runtime. Can add more into it to fits your needs.
+type LogConfig struct{
+ // log library name
+ Code string `yaml:"code"`
+ // log level
+ Level string `yaml:"level"`
+ // show caller in log message
+ EnableCaller bool `yaml:"enableCaller"`
+}
+
+// appConfig has all the configuration information for the application
+var appConfig *AppConfig
+
+// set whether to reload the configuration file. After it is loaded, it is set to false, so it only loaded once.
+var reloadConfig =true
+
+// GetAppConfig is getter for appConfig
+func GetAppConfig() *AppConfig {
+ return appConfig
+}
+
+// SetAppConfig is setter for appConfig
+func SetAppConfig(newAppConfig *AppConfig) {
+ appConfig = newAppConfig
+}
+
+// GetReloadConfig is getter for reloadConfig
+func GetReloadConfig() bool {
+ return reloadConfig
+}
+
+// SetReloadConfig is setter for reloadConfig
+func SetReloadConfig(b bool) {
+ reloadConfig = b
+}
+
+// ReadConfig reads the file of the filename (in the same folder) and put it into the AppConfig
+func ReadConfig(filename string) (AppConfig, error) {
+ var ac AppConfig
+ file, err :=ioutil.ReadFile(filename)
+ if err != nil {
+ return ac, errors.Wrap(err, "read error")
+ }
+ err = yaml.Unmarshal(file, &ac)
+
+ if err != nil {
+ return ac, errors.Wrap(err, "unmarshal")
+ }
+ fmt.Println("appConfig:", ac)
+ return ac, nil
+}
\ No newline at end of file
diff --git a/configs/appConfigDev.yaml b/configs/appConfigDev.yaml
new file mode 100644
index 0000000..1f4d2a4
--- /dev/null
+++ b/configs/appConfigDev.yaml
@@ -0,0 +1,31 @@
+mySQLConfig: &mySqlConfig
+ code: mysql
+ driverName: mysql
+ dataSourceName: "root:@tcp(localhost:4333)/service_config?charset=utf8"
+ dbName:
+couchdbConfig: &couchdbConfig
+ code: couch
+ driverName: couch
+ dataSourceName: http://admin:admin@localhost:5984
+ dbName: animals
+cacheGrpcConfig: &cacheConfig
+ code: cache
+ grpcName: cache
+ target: localhost:5051
+zapConfig: &zapConfig
+ code: zap
+ level: debug
+ enableCaller: true
+logrusConfig: &logrusConfig
+ code: logrus
+ level: info
+ enableCaller: false
+logConfig: *zapConfig
+useCaseConfig:
+ registration:
+ code: registration
+ userConfig: *mySqlConfig
+ listUser:
+ code: listUser
+ userConfig: *mySqlConfig
+ cacheConfig: *cacheConfig
diff --git a/configs/appConfigProd.yaml b/configs/appConfigProd.yaml
new file mode 100644
index 0000000..1744d22
--- /dev/null
+++ b/configs/appConfigProd.yaml
@@ -0,0 +1,31 @@
+mySQLConfig: &mySqlConfig
+ code: mysql
+ driverName: mysql
+ dataSourceName: "root:@tcp(localhost:4333)/fasp?charset=utf8"
+ dbName:
+couchdbConfig: &couchdbConfig
+ code: couch
+ driverName: couch
+ dataSourceName: http://admin:admin@localhost:5984
+ dbName: service_config
+cacheGrpcConfig: &cacheConfig
+ code: cache
+ grpcName: cache
+ target: localhost:5051
+zapConfig: &zapConfig
+ code: zap
+ level: debug
+ enableCaller: true
+logrusConfig: &logrusConfig
+ code: logrus
+ level: debug
+ enableCaller: false
+logConfig: *zapConfig
+useCaseConfig:
+ registration:
+ code: registration
+ userConfig: *couchdbConfig
+ listUser:
+ code: listUser
+ userConfig: *couchdbConfig
+ cacheConfig: *cacheConfig
diff --git a/dataservice/coursedata/courseData.go b/dataservice/coursedata/courseData.go
new file mode 100644
index 0000000..b34d16c
--- /dev/null
+++ b/dataservice/coursedata/courseData.go
@@ -0,0 +1,3 @@
+// Package coursedata is created to show the project structure, no implementation needed
+package coursedata
+
diff --git a/dataservice/dataservice.go b/dataservice/dataservice.go
new file mode 100644
index 0000000..4c1ba2d
--- /dev/null
+++ b/dataservice/dataservice.go
@@ -0,0 +1,53 @@
+// Package dataservice and it's sub-package represents data related operations, mainly access local data store,
+// for example, database.
+// This is the top level package and it only defines interface, and all implementations are defined in sub-package
+// Use case package depends on it.
+package dataservice
+
+import (
+ "github.com/jfeng45/servicetmpl/model"
+)
+
+// UserDataInterface represents interface for use data access through local database
+type UserDataInterface interface {
+ // Remove deletes a user by user name from database.
+ Remove(username string) (rowsAffected int64, err error)
+ // Find retrieves a user from database based on a user's id
+ Find(id int) (*model.User, error)
+ // FindByName retrieves a user from database by User.Name
+ FindByName(name string) (user *model.User, err error)
+ // FindAll retrieves all users from database as an array of user
+ FindAll() ([]model.User, error)
+ // Update changes user information on the User.Id passed in.
+ Update(user *model.User) (rowsAffected int64, err error)
+ // Insert adds a user to a database. The returned resultUser has a Id, which is auto generated by database
+ Insert(user *model.User) (resultUser *model.User, err error)
+ //need to add this interface if the interface needs transaction
+ TxDataService
+}
+
+// CacheDataInterface represents interface for cache service operations
+type CacheDataInterface interface {
+ // Get handles call to Get function on Cache service
+ Get(key string) ([]byte, error)
+ // Store handles call to Store function on Cache service
+ Store(key string, value []byte) error
+}
+
+// CacheDataInterface represents interface for course data service operations.
+// It is created to illustrate project layout, no real use.
+type CourseDataInterface interface {
+ GetAvailableCourse()
+}
+
+// TxDataService represents operations needed for transaction support.
+type TxDataService interface {
+ // TxBegin starts a transaction. It gets a DB handler from the receiver and return a UserDataInterface, which has a
+ // *sql.Tx inside. Any following data access will go through the *sql.Tx wrapped inside the UserDataInterface
+ TxBegin() (UserDataInterface, error)
+ // TxEnd is called at the end of a transaction and based on whether there is a error, it commits or rollback the
+ // transaction.
+ // txFunc is the business function wrapped in a transaction
+ TxEnd( txFunc func() error ) error
+}
+
diff --git a/dataservice/gdbc/gdbc.go b/dataservice/gdbc/gdbc.go
new file mode 100644
index 0000000..d69d281
--- /dev/null
+++ b/dataservice/gdbc/gdbc.go
@@ -0,0 +1,63 @@
+// Package handles low level database access including transaction through *sql.Tx or *sql.DB
+
+package gdbc
+
+import (
+ "database/sql"
+)
+
+// Gdbc (Go database connection) is a wrapper for database handler ( can be *sql.DB or *sql.Tx) in order to handle both
+type Gdbc interface {
+ Exec(query string, args ...interface{}) (sql.Result, error)
+ Prepare(query string) (*sql.Stmt, error)
+ Query(query string, args ...interface{}) (*sql.Rows, error)
+ QueryRow(query string, args ...interface{}) *sql.Row
+ //if need transaction support, need to add this interface
+ Transactioner
+}
+
+// DBTx is the concrete implementation of GDBC by using *sql.DB
+type DBTx struct {
+ DB *sql.DB
+}
+
+// ConnTx is the concrete implementation of GDBC by using *sql.Tx
+type ConnTx struct {
+ DB *sql.Tx
+}
+
+func (db *DBTx) Exec(query string, args ...interface{}) (sql.Result, error) {
+ return db.DB.Exec(query, args...)
+}
+
+func (db *DBTx) Prepare(query string) (*sql.Stmt, error) {
+ return db.DB.Prepare(query)
+}
+
+func (db *DBTx) Query(query string, args ...interface{}) (*sql.Rows, error) {
+ return db.DB.Query(query, args...)
+}
+
+func (db *DBTx) QueryRow(query string, args ...interface{}) *sql.Row {
+ return db.DB.QueryRow(query, args...)
+}
+
+func (db *ConnTx) Exec(query string, args ...interface{}) (sql.Result, error) {
+ return db.DB.Exec(query, args...)
+}
+
+func (db *ConnTx) Prepare(query string) (*sql.Stmt, error) {
+ return db.DB.Prepare(query)
+}
+
+func (db *ConnTx) Query(query string, args ...interface{}) (*sql.Rows, error) {
+ return db.DB.Query(query, args...)
+}
+
+func (db *ConnTx) QueryRow(query string, args ...interface{}) *sql.Row {
+ return db.DB.QueryRow(query, args...)
+}
+
+
+
+
diff --git a/dataservice/gdbc/transaction.go b/dataservice/gdbc/transaction.go
new file mode 100644
index 0000000..0224156
--- /dev/null
+++ b/dataservice/gdbc/transaction.go
@@ -0,0 +1,77 @@
+package gdbc
+
+import (
+ "fmt"
+ "github.com/jfeng45/servicetmpl/tools"
+)
+
+// Transactioner is the transaction interface for database handler
+type Transactioner interface {
+ // Rollback a tranaction
+ Rollback() error
+ // Commit a transaction
+ Commit() error
+ // TxEnd commits a transaction if no errors, otherwise rollback
+ // txFunc is the operations wrapped in a transaction
+ TxEnd( txFunc func() error) error
+ // TxBegin gets *sql.DB from receiver and return a Gdbc, which has a *sql.Tx
+ TxBegin() (Gdbc, error)
+}
+
+// DB doesnt rollback, do nothing here
+func (db *DBTx) Rollback() error {
+ return nil
+}
+
+//DB doesnt commit, do nothing here
+func (db *DBTx) Commit() error {
+ return nil
+}
+// TransactionBegin starts a transaction
+func (db *DBTx)TxBegin( ) (Gdbc, error) {
+ fmt.Println("transaction begin")
+ tx, err := db.DB.Begin()
+ ct := ConnTx{tx}
+ return &ct, err
+}
+// DB doesnt rollback, do nothing here
+func (db *DBTx)TxEnd( txFunc func() error) error {
+ return nil
+}
+
+func (db *ConnTx) TxEnd( txFunc func() error) error {
+ var err error
+ tx := db.DB
+
+ defer func() {
+ if p := recover(); p != nil {
+ tools.Log.Debug("found p and rollback:", p)
+ tx.Rollback()
+ panic(p) // re-throw panic after Rollback
+ } else if err != nil {
+ tools.Log.Debugf("found error and rollback:", err)
+ tx.Rollback() // err is non-nil; don't change it
+ } else {
+ tools.Log.Debug("commit:")
+ err = tx.Commit() // if Commit returns error update err with commit err
+ }
+ }()
+ err = txFunc()
+ return err
+}
+//*sql.Tx can't begin a transaction, transaction always begins with a *sql.DB
+func (db *ConnTx) TxBegin( ) (Gdbc, error) {
+ return nil, nil
+}
+
+func (db *ConnTx) Rollback() error {
+ return db.DB.Rollback()
+}
+
+func (db *ConnTx) Commit() error {
+ return db.DB.Commit()
+}
+
+
+
+
diff --git a/dataservice/userdata/couchdb/userDataCouchdb.go b/dataservice/userdata/couchdb/userDataCouchdb.go
new file mode 100644
index 0000000..b3e326f
--- /dev/null
+++ b/dataservice/userdata/couchdb/userDataCouchdb.go
@@ -0,0 +1,103 @@
+// Package mysql represents the CouchDB implementation of the user data persistence layer
+package couchdb
+
+import (
+ "context"
+ "github.com/go-kivik/kivik"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+)
+
+type UserDataCouchdb struct {
+ DB *kivik.DB
+}
+
+// Create a view for "Find()", only need to run once.
+// Should be created by Fauxton, but you may not know how to do it. To make it easy for you, put it in code.
+// This function is created to make it easy to run the application, don't do it in production code
+// When run for more than once, it will show error "Conflict: Document update conflict", just ignore it
+func createView(dataStore *UserDataCouchdb) {
+ rev, err := dataStore.DB.Put(context.TODO(), "_design/serviceConfigDesignDoc", map[string]interface{}{
+ "_id": "_design/serviceConfigDesignDoc",
+ "views": map[string]interface{}{
+ "serviceConfigByID": map[string]interface{}{
+ "map": "function(doc) {\n if (doc.uid) {\n emit(doc.uid, doc);\n}\n}",
+ },
+ },
+ "language":"javascript",
+ })
+ // For each rnu after first, it will throw an error because it already exist. Just ignore it.
+ if err != nil {
+ tools.Log.Errorf("err:%v\n" , err)
+ }
+ tools.Log.Debug("rev:", rev)
+}
+
+func (dataStore *UserDataCouchdb) Find(id int) (*model.User, error) {
+ var err error
+ // only need to it once
+ createView(dataStore)
+ rows, err := dataStore.DB.Query(context.TODO(), "_design/serviceConfigDesignDoc", "_view/serviceConfigByID", map[string]interface{}{"reduce": false},
+ kivik.Options{"key":id})
+
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ var user *model.User
+ if rows.Next() {
+ user = &model.User{}
+ if err := rows.ScanValue(user); err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ }
+ tools.Log.Debugf("view:%+v", user)
+
+ if rows.Err() != nil {
+ return nil, errors.Wrap(rows.Err(), "")
+ }
+ return user, nil
+}
+
+//The simple version (no need for view) of Find() to get it work, it is kind cheating because it didn't use the parameter id.
+//func (dataStore *UserDataCouchdb) Find(id int) (*model.User, error) {
+// _id :="80a9134c7dfa53f67f6be214e1000fa7"
+// row, err :=dataStore.DB.Get(context.TODO(), _id)
+// if err != nil {
+// return nil, errors.Wrap(err, "")
+// }
+// var user model.User
+// if err=row.ScanDoc(&user); err!=nil {
+// panic(err)
+// }
+// logger.Log.Debugf("user:", user)
+// return &user, nil
+//}
+
+func (dataStore *UserDataCouchdb) Remove(username string) (int64, error) {
+
+ return 0, nil
+}
+func (dataStore *UserDataCouchdb) Update(user *model.User) (int64, error) {
+ return 0, nil
+}
+
+func (dataStore *UserDataCouchdb) Insert(user *model.User) (*model.User, error) {
+ return nil, nil
+}
+func (dataStore *UserDataCouchdb) FindAll() ([]model.User, error) {
+ return []model.User{}, nil
+}
+func (dataStore *UserDataCouchdb) FindByName(name string) (*model.User, error) {
+ return nil, nil
+}
+
+//CouchDB doesn't support transaction, do nothing
+func (dataStore *UserDataCouchdb)TxEnd( txFunc func() error) error {
+ return nil
+}
+//CouchDB doesn't support transaction, do nothing
+func (dataStore *UserDataCouchdb)TxBegin() (dataservice.UserDataInterface, error) {
+ return nil, nil
+}
diff --git a/dataservice/userdata/mysql/userDataMysql.go b/dataservice/userdata/mysql/userDataMysql.go
new file mode 100644
index 0000000..27e7a25
--- /dev/null
+++ b/dataservice/userdata/mysql/userDataMysql.go
@@ -0,0 +1,159 @@
+// Package mysql represents the mySQL implementation of the user data persistence layer
+package mysql
+
+import (
+ "database/sql"
+ _ "github.com/go-sql-driver/mysql"
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/dataservice/gdbc"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+ "time"
+)
+
+// DBTxStore is the MySQL implementation of Gdbc interface
+type DBTxStore struct {
+ DB gdbc.Gdbc
+}
+
+func (userData *DBTxStore) Remove(username string) (int64, error) {
+
+ stmt, err := userData.DB.Prepare("delete from userinfo where username=?")
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+ defer stmt.Close()
+
+ res, err := stmt.Exec(username)
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+ rowsAffected, err := res.RowsAffected()
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+
+ tools.Log.Debug("remove:row affected ", rowsAffected)
+ return rowsAffected, nil
+}
+
+func (userData *DBTxStore) Find(id int) (*model.User, error) {
+ rows, err := userData.DB.Query("SELECT * FROM userinfo where uid =?", id)
+ if err!=nil {
+ return nil, errors.Wrap(err, "")
+ }
+ defer rows.Close()
+ return retrieveUser(rows)
+ //return user, nil
+}
+func retrieveUser(rows *sql.Rows) (*model.User, error) {
+ if rows.Next() {
+ return rowsToUser(rows)
+ }
+ return nil, nil
+}
+func rowsToUser(rows *sql.Rows) (*model.User, error) {
+ var ds string
+ user := &model.User{}
+ err := rows.Scan(&user.Id, &user.Name, &user.Department, &ds)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ created, err := time.Parse(tools.FORMAT_ISO8601_DATE, ds)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ user.Created = created
+
+ tools.Log.Debug("rows to User:", user)
+ return user, nil
+}
+func (userData *DBTxStore) FindByName(name string) (*model.User, error) {
+ rows, err := userData.DB.Query("SELECT * FROM userinfo where username =?", name)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ defer rows.Close()
+ return retrieveUser(rows)
+ //return nil, nil
+}
+
+func (userData *DBTxStore) FindAll() ([]model.User, error) {
+
+ rows, err := userData.DB.Query("SELECT * FROM userinfo ")
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ defer rows.Close()
+ users := []model.User{}
+
+ //var ds string
+ for rows.Next() {
+ user, err :=rowsToUser(rows)
+ if err != nil {
+ return users, errors.Wrap(err,"")
+ }
+ users = append(users, *user)
+
+ }
+ //need to check error for rows.Next()
+ if err =rows.Err(); err!= nil {
+ return nil, errors.Wrap(err, "")
+ }
+ tools.Log.Debug("find user list:", users)
+ return users, nil
+}
+
+func (userData *DBTxStore) Update(user *model.User) (int64, error) {
+
+ stmt, err := userData.DB.Prepare("update userinfo set username=?, department=?, created=? where uid=?")
+
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+ defer stmt.Close()
+ res, err := stmt.Exec(user.Name, user.Department, user.Created, user.Id)
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+ rowsAffected, err := res.RowsAffected()
+
+ if err!=nil {
+ return 0, errors.Wrap(err, "")
+ }
+ tools.Log.Debug("update: rows affected: ", rowsAffected)
+
+ return rowsAffected, nil
+}
+
+func (userData *DBTxStore) Insert(user *model.User) (*model.User, error) {
+
+ stmt, err := userData.DB.Prepare("INSERT userinfo SET username=?,department=?,created=?")
+ if err!=nil {
+ return nil, errors.Wrap(err, "")
+ }
+ defer stmt.Close()
+ res, err := stmt.Exec(user.Name, user.Department, user.Created)
+ if err!=nil {
+ return nil, errors.Wrap(err, "")
+ }
+ id, err := res.LastInsertId()
+ if err!=nil {
+ return nil, errors.Wrap(err, "")
+ }
+ user.Id = int(id)
+ tools.Log.Debug("user inserted:", user)
+ return user, nil
+}
+
+func (dataStore *DBTxStore)TxEnd( txFunc func() error) error {
+ return dataStore.DB.TxEnd(txFunc)
+}
+
+func (dataStore *DBTxStore)TxBegin() (dataservice.UserDataInterface, error) {
+
+ gdbc, error :=dataStore.DB.TxBegin()
+ dbts := DBTxStore{gdbc}
+ return &dbts, error
+}
\ No newline at end of file
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..c70dcfa
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,21 @@
+module github.com/jfeng45/servicetmpl
+
+go 1.12
+
+require (
+ github.com/flimzy/kivik v1.8.1 // indirect
+ github.com/go-kivik/couchdb v1.8.1
+ github.com/go-kivik/kivik v1.8.1
+ github.com/go-ozzo/ozzo-validation v3.5.0+incompatible
+ github.com/go-sql-driver/mysql v1.4.1
+ github.com/golang/protobuf v1.3.1
+ github.com/imdario/mergo v0.3.7 // indirect
+ github.com/pkg/errors v0.8.1
+ github.com/sirupsen/logrus v1.4.2
+ go.uber.org/atomic v1.4.0 // indirect
+ go.uber.org/multierr v1.1.0 // indirect
+ go.uber.org/zap v1.10.0
+ golang.org/x/net v0.0.0-20190603091049-60506f45cf65
+ google.golang.org/grpc v1.21.1
+ gopkg.in/yaml.v2 v2.2.2
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..7aa3e48
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,58 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/flimzy/kivik v1.8.1 h1:URl7e0OnfSvAu3ZHQ5BkvzRZlCmyYuDyWUCcPWIHlU0=
+github.com/flimzy/kivik v1.8.1/go.mod h1:S2aPycbG0eDFll4wgXt9uacSNkXISPufutnc9sv+mdA=
+github.com/go-kivik/couchdb v1.8.1 h1:2yjmysS48JYpyWTkx2E3c7ASZP8Kh0eABWnkKlV8bbw=
+github.com/go-kivik/couchdb v1.8.1/go.mod h1:5XJRkAMpBlEVA4q0ktIZjUPYBjoBmRoiWvwUBzP3BOQ=
+github.com/go-kivik/kivik v1.8.1 h1:GScP1mS5wP2km2awszvKzPEjC21lYjQGr3GY+4a/o2U=
+github.com/go-kivik/kivik v1.8.1/go.mod h1:nIuJ8z4ikBrVUSk3Ua8NoDqYKULPNjuddjqRvlSUyyQ=
+github.com/go-ozzo/ozzo-validation v3.5.0+incompatible h1:sUy/in/P6askYr16XJgTKq/0SZhiWsdg4WZGaLsGQkM=
+github.com/go-ozzo/ozzo-validation v3.5.0+incompatible/go.mod h1:gsEKFIVnabGBt6mXmxK0MoFy+cZoTJY6mu5Ll3LVLBU=
+github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
+github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
+github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/model/cache.go b/model/cache.go
new file mode 100644
index 0000000..1cebfe4
--- /dev/null
+++ b/model/cache.go
@@ -0,0 +1,8 @@
+package model
+
+//Cache is the domain model for cache service
+type Cache struct {
+ key string
+ value []byte
+}
+
diff --git a/model/course.go b/model/course.go
new file mode 100644
index 0000000..7dab844
--- /dev/null
+++ b/model/course.go
@@ -0,0 +1,7 @@
+package model
+
+// Course is created to show the project layout, no real use.
+type Course struct {
+ Id int
+ name string
+}
\ No newline at end of file
diff --git a/model/user.go b/model/user.go
new file mode 100644
index 0000000..59fb2f4
--- /dev/null
+++ b/model/user.go
@@ -0,0 +1,37 @@
+// Package model represents business domain model. Every domain model type should have it's own file.
+// It shouldn't depends on any other package in the application
+// It should only has domain model type and limited domain logic, in this example, validation logic. Because all other
+// package depends on this package, the import of this package should be as small as possible.
+
+
+package model
+
+import (
+ "time"
+ "github.com/go-ozzo/ozzo-validation"
+)
+
+// User has a name, department and created date. Name and created are required, department is optional.
+// Id is auto-generated by database after the user is persisted.
+type User struct {
+ Id int `json:"uid"`
+ Name string `json:"username"`
+ Department string `json:"department"`
+ Created time.Time `json:"created"`
+}
+
+//Validate validate a newly created user, which has not persisted to database yet, so Id is empty
+func (u User) Validate() error{
+ return validation.ValidateStruct (&u,
+ validation.Field(&u.Name, validation.Required),
+ validation.Field(&u.Created, validation.Required))
+}
+
+//ValidatePersist validate a user that has been persisted to database, basically Id is not empty
+func (u User) ValidatePersist() error{
+ return validation.ValidateStruct (&u,
+ validation.Field(&u.Id, validation.Required),
+ validation.Field(&u.Name, validation.Required),
+ validation.Field(&u.Created, validation.Required))
+}
+
diff --git a/scripts/user.sql b/scripts/user.sql
new file mode 100644
index 0000000..114d5a4
--- /dev/null
+++ b/scripts/user.sql
@@ -0,0 +1,20 @@
+/*
+SQLyog Ultimate
+MySQL - 5.0.96-community-log : Database - fasp
+*********************************************************************
+*/
+
+CREATE DATABASE `service_config` ;
+
+/*Table structure for table `userinfo` */
+
+DROP TABLE IF EXISTS `userinfo`;
+
+CREATE TABLE `userinfo` (
+ `uid` int(10) NOT NULL auto_increment,
+ `username` varchar(64) default NULL,
+ `department` varchar(64) default NULL,
+ `created` date default NULL,
+ PRIMARY KEY (`uid`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
diff --git a/tools/doc.go b/tools/doc.go
new file mode 100644
index 0000000..c1d57a1
--- /dev/null
+++ b/tools/doc.go
@@ -0,0 +1,4 @@
+// Package tools represents a wrapper to third party library. It may enhance or modify some of the functionalities
+// of a third party library or create a interface for it.
+
+package tools
diff --git a/tools/logger.go b/tools/logger.go
new file mode 100644
index 0000000..f96db19
--- /dev/null
+++ b/tools/logger.go
@@ -0,0 +1,26 @@
+// Package tools represents a wrapper to third party library. It may enhance or modify some of the functionalities
+// of a third party library or create a interface for it.
+
+package tools
+
+// Log is a package level variable, every program should access logging function through "Log"
+var Log Logger
+
+// Logger represent common interface for logging function
+type Logger interface {
+ Errorf(format string, args ...interface{})
+ Fatalf(format string, args ...interface{})
+ Fatal(args ...interface{})
+ Infof(format string, args ...interface{})
+ Info( args ...interface{})
+ Warnf(format string, args ...interface{})
+ Debugf(format string, args ...interface{})
+ Debug(args ...interface{})
+}
+
+// SetLogger is the setter for log variable, it should be the only way to assign value to log
+func SetLogger(newLogger Logger) {
+ Log=newLogger
+}
+
+
diff --git a/tools/timea.go b/tools/timea.go
new file mode 100644
index 0000000..d5b40d5
--- /dev/null
+++ b/tools/timea.go
@@ -0,0 +1,14 @@
+package tools
+
+// the following constants represents different data format layout
+const (
+ FORMAT_ISO8601_DATE = "2006-01-02"
+ FORMAT_ISO8601_DATE_TIME = "2006-01-02 15:04:05"
+ FORMAT_ISO8601_DATE_TIME_MILLI ="2006-01-02 15:04:05.000"
+ FORMAT_ISO8601_DATE_TIME_MILLI_ZONE = "2006-01-02 15:04:05.000Z07:00"
+ FORMAT_ISO8601_DATE_TIME_MICRO = "2006-01-02 15:04:05.000000"
+ FORMAT_ISO8601_DATE_TIME_MICRO_ZONE = "2006-01-02 15:04:05.000000Z07:00"
+ FORMAT_ISO8601_DATE_TIME_NANO = "2006-01-02 15:04:05.000000000"
+ FORMAT_ISO8601_DATE_TIME_NANO_ZONE ="2006-01-02 15:04:05.00000000007:00"
+)
+
diff --git a/usecase/listuser/listUser.go b/usecase/listuser/listUser.go
new file mode 100644
index 0000000..7fa33f9
--- /dev/null
+++ b/usecase/listuser/listUser.go
@@ -0,0 +1,47 @@
+// Package registration represents the concrete implementation of ListUserUseCaseInterface interface
+package listuser
+
+import (
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/jfeng45/servicetmpl/tools"
+ "github.com/pkg/errors"
+ "strconv"
+)
+
+// RegistrationUseCase implements RegistrationUseCaseInterface.
+
+type ListUserUseCase struct {
+ // UserDataInterface, which is a interface to underline database connection and can be used to access
+ // persistence layer
+ UserDataInterface dataservice.UserDataInterface
+ // CacheDataInterface, which is a interface to outside gRPC cache service and can be used to access gRPC service
+ CacheDataInterface dataservice.CacheDataInterface
+}
+
+func (uuc *ListUserUseCase) ListUser() ([]model.User, error) {
+ return uuc.UserDataInterface.FindAll()
+}
+func (uuc *ListUserUseCase)Find(id int) (*model.User,error) {
+ users, err := uuc.getFromCache(strconv.Itoa(id))
+ if err != nil {
+ tools.Log.Errorf("get from cache error:", err)
+ }
+ if users != nil {
+ //here should return the results from cache, however, right now the cache doesn't store user info,
+ //so, just call find(id). This is not real code. Please replace it with real code
+ return uuc.UserDataInterface.Find(id)
+ }
+ return uuc.UserDataInterface.Find(id)
+}
+
+// getFromCache is a fake function to just show a call to outside service, the call to outside is working, but the results returned is not right
+func (uuc *ListUserUseCase) getFromCache(key string) ([]model.User, error) {
+ value, err := uuc.CacheDataInterface.Get(key)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ tools.Log.Info("value from get cache: ", value)
+ return nil, nil
+}
+
diff --git a/usecase/registration/registrationHelper.go b/usecase/registration/registrationHelper.go
new file mode 100644
index 0000000..1a70cee
--- /dev/null
+++ b/usecase/registration/registrationHelper.go
@@ -0,0 +1,56 @@
+package registration
+
+import (
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/pkg/errors"
+ "strconv"
+)
+
+func modifyUser(udi dataservice.UserDataInterface, user *model.User) error {
+ //loggera.Log.Debug("modifyUser")
+ err :=user.ValidatePersist()
+ if err != nil {
+ return errors.Wrap(err, "user validation failed")
+ }
+ rowsAffected, err := udi.Update(user)
+ if err!= nil {
+ return errors.Wrap(err, "")
+ }
+ if rowsAffected != 1 {
+ return errors.New("Modify user failed. rows affected is " + strconv.Itoa(int(rowsAffected)))
+ }
+ return nil
+}
+
+func unregisterUser(udi dataservice.UserDataInterface, username string) error {
+ affected, err := udi.Remove(username)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ if affected == 0 {
+ errStr := "UnregisterUser failed. No such user " + username
+ return errors.New(errStr)
+ }
+
+ if affected != 1 {
+ errStr :="UnregisterUser failed. Number of users unregistered are " + strconv.Itoa(int(affected))
+ return errors.New(errStr)
+ }
+ return nil
+}
+
+// The business function will be wrapped inside a transaction and without a transaction
+// It needs to be written in a way that every error will be returned so it can be catched by TxEnd() function, which will handle commit and rollback
+func modifyAndUnregister(udi dataservice.UserDataInterface, user *model.User) error {
+ //loggera.Log.Debug("modifyAndUnregister")
+ err := modifyUser(udi, user)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ err = unregisterUser(udi, user.Name)
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ return nil
+}
\ No newline at end of file
diff --git a/usecase/registration/registraton.go b/usecase/registration/registraton.go
new file mode 100644
index 0000000..eedb080
--- /dev/null
+++ b/usecase/registration/registraton.go
@@ -0,0 +1,72 @@
+// Package registration represents the concrete implementation of RegistrationUseCaseInterface interface
+// Because the same business function can be created to support both transaction and non-transaction, the business
+// function need to be created to support both. So, the shared business function is created in a helper file and
+// the wrapper of that function to support transaction and non-transaction are created in a file to
+// implement use case
+package registration
+
+import (
+ "github.com/jfeng45/servicetmpl/dataservice"
+ "github.com/jfeng45/servicetmpl/model"
+ "github.com/pkg/errors"
+)
+// RegistrationUseCase implements RegistrationUseCaseInterface. It has UserDataInterface, which can be used to
+// access persistence layer
+type RegistrationUseCase struct {
+ UserDataInterface dataservice.UserDataInterface
+}
+
+func (uuc *RegistrationUseCase) RegisterUser(user *model.User) (*model.User, error) {
+ err :=user.Validate()
+ if err != nil {
+ return nil, errors.Wrap(err, "user validation failed")
+ }
+ isDup, err := uuc.isDuplicate(user.Name)
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ if isDup {
+ return nil, errors.New("duplicate user for " + user.Name)
+ }
+ resultUser, err :=uuc.UserDataInterface.Insert(user)
+
+ if err != nil {
+ return nil, errors.Wrap(err, "")
+ }
+ return resultUser, nil
+}
+
+func (uuc *RegistrationUseCase) ModifyUser(user *model.User) error {
+ return modifyUser(uuc.UserDataInterface, user)
+}
+
+func (uuc *RegistrationUseCase) isDuplicate(name string) (bool, error) {
+ user, err :=uuc.UserDataInterface.FindByName(name)
+ if err != nil {
+ return false, errors.Wrap(err, "")
+ }
+ if user != nil {
+ return true, nil
+ }
+ return false, nil
+}
+
+func (uuc *RegistrationUseCase) UnregisterUser(username string) error {
+ return unregisterUser(uuc.UserDataInterface, username)
+}
+
+// The use case of ModifyAndUnregister without transaction
+func (uuc *RegistrationUseCase) ModifyAndUnregister(user *model.User) error {
+ return modifyAndUnregister(uuc.UserDataInterface, user)
+}
+// The use case of ModifyAndUnregister with transaction
+func (uuc *RegistrationUseCase) ModifyAndUnregisterWithTx(user *model.User) error {
+ newUdi, err := uuc.UserDataInterface.TxBegin()
+ if err != nil {
+ return errors.Wrap(err, "")
+ }
+ return newUdi.TxEnd( func () error {
+ //wrap the business function inside the TxEnd function
+ return modifyAndUnregister(newUdi, user)
+ })
+}
diff --git a/usecase/useCase.go b/usecase/useCase.go
new file mode 100644
index 0000000..6ad00a0
--- /dev/null
+++ b/usecase/useCase.go
@@ -0,0 +1,43 @@
+// Package usecase defines all the interfaces for a Microservice application.
+// It is the entry point for the application's business logic. It is a top level package for a Microservice application.
+// This top level only defines interface, the concrete implementations are defined in sub-package of it.
+// It only depends on model package. No other package should dependent on it.
+
+// If transaction is supported, the transaction boundary should be defined in this package.
+// A suffix-"WIthTx" can be added to the name of a function to distinguish it from a non-transaction one.
+
+// The use case example, which are not real world use case, are created to illustrate the project layout. You should
+// replace them with your real use case.
+
+package usecase
+
+import (
+ "github.com/jfeng45/servicetmpl/model"
+)
+
+// RegistrationUseCaseInterface is for users to register themselves to an application. It has registration related functions.
+// ModifyAndUnregisterWithTx() is the one support transaction, the other are not.
+type RegistrationUseCaseInterface interface {
+ // RegisterUser register a user to an application, basically save it to a database. The returned resultUser that has
+ // a Id ( auto generated by database) after persisted
+ RegisterUser(user *model.User) (resultUser *model.User, err error)
+ // UnregisterUser unregister a user by user name from an application, basically remove it from a database.
+ UnregisterUser(username string) error
+ // ModifyUser change user information on the User.Id passed in.
+ ModifyUser(user *model.User) error
+ // ModifyAndUnregister change user information and then unregister the user on the User.Id passed in.
+ // It is create to illustrate transaction, no real use.
+ ModifyAndUnregister(user *model.User) error
+ // ModifyAndUnregisterWithTx change user information and then unregister the user on the User.Id passed in.
+ // It supports transaction
+ // It is create to illustrate transaction, no real use.
+ ModifyAndUnregisterWithTx(user *model.User) error
+}
+
+// ListUserUseCaseInterface handles different ways to retrieve user information
+type ListUserUseCaseInterface interface {
+ // ListUser retrieves all users as an array of user
+ ListUser() ([]model.User, error)
+ // Find retrieves a user based on a user's id
+ Find(id int) (*model.User, error)
+}