Skip to content

Commit 915d2e4

Browse files
author
zhangming03
committed
register-postgresqlStore
1 parent d6d66b5 commit 915d2e4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

pgstore.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
package pgstore
1919

2020
import (
21+
"github.com/polaris-contrib/store-postgresql/store/postgresql"
2122
"github.com/polarismesh/polaris/common/log"
2223
"github.com/polarismesh/polaris/store"
23-
24-
"github.com/polaris-contrib/store-postgresql/store/postgresql"
2524
)
2625

2726
func init() {

store/postgresql/default.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const (
1919
emptyEnableTime = "STR_TO_DATE('1980-01-01 00:00:01', '%Y-%m-%d %H:%i:%s')"
2020
)
2121

22-
// postgresqlStore 实现了Store接口
23-
type postgresqlStore struct {
22+
// PostgresqlStore 实现了Store接口
23+
type PostgresqlStore struct {
2424
*namespaceStore
2525
// client info stores
2626
*clientStore
@@ -66,12 +66,12 @@ type postgresqlStore struct {
6666
}
6767

6868
// Name 实现Name函数
69-
func (p *postgresqlStore) Name() string {
69+
func (p *PostgresqlStore) Name() string {
7070
return STORENAME
7171
}
7272

7373
// Initialize 初始化函数
74-
func (p *postgresqlStore) Initialize(conf *store.Config) error {
74+
func (p *PostgresqlStore) Initialize(conf *store.Config) error {
7575
if p.start {
7676
return nil
7777
}
@@ -115,7 +115,7 @@ func (p *postgresqlStore) Initialize(conf *store.Config) error {
115115
}
116116

117117
// Destroy 退出函数
118-
func (p *postgresqlStore) Destroy() error {
118+
func (p *PostgresqlStore) Destroy() error {
119119
p.start = false
120120

121121
if p.master != nil {
@@ -140,7 +140,7 @@ func (p *postgresqlStore) Destroy() error {
140140
}
141141

142142
// CreateTransaction 创建一个事务
143-
func (p *postgresqlStore) CreateTransaction() (store.Transaction, error) {
143+
func (p *PostgresqlStore) CreateTransaction() (store.Transaction, error) {
144144
// 每次创建事务前,还是需要ping一下
145145
_ = p.masterTx.Ping()
146146

@@ -156,7 +156,7 @@ func (p *postgresqlStore) CreateTransaction() (store.Transaction, error) {
156156
return nt, nil
157157
}
158158

159-
func (p *postgresqlStore) StartTx() (store.Tx, error) {
159+
func (p *PostgresqlStore) StartTx() (store.Tx, error) {
160160
tx, err := p.masterTx.Begin()
161161
if err != nil {
162162
return nil, err
@@ -235,7 +235,7 @@ func parseStoreConfig(opts interface{}) (*dbConfig, error) {
235235
}
236236

237237
// newStore 初始化子类
238-
func (p *postgresqlStore) newStore() {
238+
func (p *PostgresqlStore) newStore() {
239239
p.namespaceStore = &namespaceStore{master: p.master, slave: p.slave}
240240

241241
p.serviceStore = &serviceStore{master: p.master, slave: p.slave}
@@ -280,7 +280,7 @@ func (p *postgresqlStore) newStore() {
280280
}
281281

282282
func init() {
283-
s := &postgresqlStore{}
283+
s := &PostgresqlStore{}
284284
err := store.RegisterStore(s)
285285
if err != nil {
286286
log.Errorf("[Store][database] RegisterStore err: %+v", err)

0 commit comments

Comments
 (0)