Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Dec 1, 2022
1 parent 4bc67f4 commit 9a02781
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/factory/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (c *Cluster) SetMaster(index int, database db.Database) error {
// SetSlave : set read-only database
func (c *Cluster) SetSlave(index int, database db.Database) error {
c.setSlaveLogger(database)
if len(c.masters) > index {
if len(c.slaves) > index {
c.slaves[index] = database
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion lib/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (f *Factory) SetCluster(index int, cluster *Cluster, names ...string) *Fact
}

func (f *Factory) SetIndexName(index int, name string) *Factory {
if len(f.databases) >= index {
if len(f.databases) <= index {
panic("[Factory.SetIndexName(" + fmt.Sprintf("%d, %q", index, name) + ")] index out of bounds: " + fmt.Sprintf("%d", len(f.databases)-1))
}
f.names[name] = index
Expand Down

0 comments on commit 9a02781

Please sign in to comment.