From 8353ce81e901e6dbf057f8c540d34e82e3308f08 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 26 Sep 2017 11:29:41 +0800 Subject: [PATCH] rename and comments --- engine_group.go | 14 +++++++------- engine_group_policy.go | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/engine_group.go b/engine_group.go index fe51f30f..88d0db0f 100644 --- a/engine_group.go +++ b/engine_group.go @@ -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 } diff --git a/engine_group_policy.go b/engine_group_policy.go index bd4ba4ae..f2efca40 100644 --- a/engine_group_policy.go +++ b/engine_group_policy.go @@ -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 }