Skip to content

pool: implemented Role Stringer interface #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
also added logs for error case of `ConnectionPool.tryConnect()` calls in
`ConnectionPool.controller()` and `ConnectionPool.reconnect()`
- Methods that are implemented but not included in the pooler interface (#395).
- Implemented stringer methods for pool.Role (#405).

### Changed

10 changes: 7 additions & 3 deletions pool/const.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:generate stringer -type Role -linecomment
package pool

/*
@@ -31,7 +32,10 @@ const (
type Role uint32

const (
UnknownRole Role = iota // A connection pool failed to discover mode of the instance.
MasterRole // The instance is read-write mode.
ReplicaRole // The instance is in read-only mode.
// UnknownRole - the connection pool was unable to detect the instance mode.
UnknownRole Role = iota // unknown
// MasterRole - the instance is in read-write mode.
MasterRole // master
// ReplicaRole - the instance is in read-only mode.
ReplicaRole // replica
)
13 changes: 13 additions & 0 deletions pool/const_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pool

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestRole_String(t *testing.T) {
require.Equal(t, "unknown", UnknownRole.String())
require.Equal(t, "master", MasterRole.String())
require.Equal(t, "replica", ReplicaRole.String())
}
25 changes: 25 additions & 0 deletions pool/role_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.