rename and comments

This commit is contained in:
Lunny Xiao 2017-09-26 11:29:41 +08:00
parent 5f5e7735c0
commit 2e5accf6f1
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 9 additions and 10 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Xorm Authors. All rights reserved.
// Copyright 2017 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@ -21,12 +21,12 @@ type EngineGroup struct {
weight []int
count int
s_count int
policy Policy
policy GroupPolicy
p int
}
func NewGroup(args1 interface{}, args2 interface{}, policies ...Policy) (*EngineGroup, error) {
var policy Policy
func NewGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) {
var policy GroupPolicy
if len(policies) > 0 {
policy = policies[0]
} else {
@ -47,7 +47,7 @@ func NewGroup(args1 interface{}, args2 interface{}, policies ...Policy) (*Engine
return nil, ErrParamsType
}
func newGroup1(driverName string, dataSourceNames string, policy Policy) (*EngineGroup, error) {
func newGroup1(driverName string, dataSourceNames string, policy GroupPolicy) (*EngineGroup, error) {
conns := strings.Split(dataSourceNames, ";")
engines := make([]*Engine, len(conns))
for i, _ := range conns {
@ -67,7 +67,7 @@ func newGroup1(driverName string, dataSourceNames string, policy Policy) (*Engin
}, nil
}
func newGroup2(Master *Engine, Slaves []*Engine, policy Policy) (*EngineGroup, error) {
func newGroup2(Master *Engine, Slaves []*Engine, policy GroupPolicy) (*EngineGroup, error) {
return &EngineGroup{
master: Master,
slaves: Slaves,
@ -77,7 +77,7 @@ func newGroup2(Master *Engine, Slaves []*Engine, policy Policy) (*EngineGroup, e
}, nil
}
func (eg *EngineGroup) SetPolicy(policy Policy) *EngineGroup {
func (eg *EngineGroup) SetPolicy(policy GroupPolicy) *EngineGroup {
eg.policy = policy
return eg
}

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Xorm Authors. All rights reserved.
// Copyright 2017 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@ -7,11 +7,10 @@ package xorm
import (
"math/rand"
"sync"
"time"
)
type Policy interface {
type GroupPolicy interface {
Slave(*EngineGroup) *Engine
}