Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #556 from tiffanyfj/tb/refactor
Browse files Browse the repository at this point in the history
perror -> serror
  • Loading branch information
geauxvirtual committed Nov 30, 2015
2 parents 9731188 + 90399ef commit e62bd3b
Show file tree
Hide file tree
Showing 22 changed files with 365 additions and 365 deletions.
20 changes: 10 additions & 10 deletions control/available_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/intelsdi-x/snap/control/plugin/client"
"github.com/intelsdi-x/snap/control/routing"
"github.com/intelsdi-x/snap/core/control_event"
"github.com/intelsdi-x/snap/core/perror"
"github.com/intelsdi-x/snap/core/serror"
)

const (
Expand Down Expand Up @@ -481,7 +481,7 @@ func (p *apPool) subscriptionCount() int {
return len(p.subs)
}

func (p *apPool) selectAP(strat RoutingStrategy) (*availablePlugin, perror.SnapError) {
func (p *apPool) selectAP(strat RoutingStrategy) (*availablePlugin, serror.SnapError) {
p.RLock()
defer p.RUnlock()

Expand All @@ -493,7 +493,7 @@ func (p *apPool) selectAP(strat RoutingStrategy) (*availablePlugin, perror.SnapE
}
sap, err := strat.Select(p, sp)
if err != nil || sap == nil {
return nil, perror.New(err)
return nil, serror.New(err)
}
return sap.(*availablePlugin), nil
}
Expand Down Expand Up @@ -563,7 +563,7 @@ func (ap *availablePlugins) insert(pl *availablePlugin) error {
if !exists {
p, err := newPool(key, pl)
if err != nil {
return perror.New(ErrBadKey, map[string]interface{}{
return serror.New(ErrBadKey, map[string]interface{}{
"key": key,
})
}
Expand All @@ -574,21 +574,21 @@ func (ap *availablePlugins) insert(pl *availablePlugin) error {
return nil
}

func (ap *availablePlugins) getPool(key string) (*apPool, perror.SnapError) {
func (ap *availablePlugins) getPool(key string) (*apPool, serror.SnapError) {
ap.RLock()
defer ap.RUnlock()
pool, ok := ap.table[key]
if !ok {
tnv := strings.Split(key, ":")
if len(tnv) != 3 {
return nil, perror.New(ErrBadKey, map[string]interface{}{
return nil, serror.New(ErrBadKey, map[string]interface{}{
"key": key,
})
}

v, err := strconv.Atoi(tnv[2])
if err != nil {
return nil, perror.New(ErrBadKey, map[string]interface{}{
return nil, serror.New(ErrBadKey, map[string]interface{}{
"key": key,
})
}
Expand All @@ -603,7 +603,7 @@ func (ap *availablePlugins) getPool(key string) (*apPool, perror.SnapError) {
return pool, nil
}

func (ap *availablePlugins) holdPool(key string) (*apPool, perror.SnapError) {
func (ap *availablePlugins) holdPool(key string) (*apPool, serror.SnapError) {
pool, err := ap.getPool(key)
if err != nil {
return nil, err
Expand All @@ -615,7 +615,7 @@ func (ap *availablePlugins) holdPool(key string) (*apPool, perror.SnapError) {
return pool, nil
}

func (ap *availablePlugins) findLatestPool(pType, name string) (*apPool, perror.SnapError) {
func (ap *availablePlugins) findLatestPool(pType, name string) (*apPool, serror.SnapError) {
// see if there exists a pool at all which matches name version.
var latest *apPool
for key, pool := range ap.table {
Expand Down Expand Up @@ -652,7 +652,7 @@ func (ap *availablePlugins) getOrCreatePool(key string) (*apPool, error) {
return pool, nil
}

func (ap *availablePlugins) selectAP(key string) (*availablePlugin, perror.SnapError) {
func (ap *availablePlugins) selectAP(key string) (*availablePlugin, serror.SnapError) {
ap.RLock()
defer ap.RUnlock()

Expand Down
Loading

0 comments on commit e62bd3b

Please sign in to comment.