Documentation
¶
Overview ¶
Package mongoadmin implements authenticated, quorum-aware MongoDB administration.
Index ¶
- func AddNonVoting(ctx context.Context, c *mongo.Client, id int, host string) error
- func AddShard(ctx context.Context, c *mongo.Client, set, hosts string) error
- func Balancer(ctx context.Context, c *mongo.Client) (string, bool, error)
- func CheckWritablePrimary(ctx context.Context, c *mongo.Client) error
- func Dial(ctx context.Context, o DialOptions) (*mongo.Client, error)
- func FCV(ctx context.Context, c *mongo.Client) (string, error)
- func Promote(ctx context.Context, c *mongo.Client, host string) error
- func ReadError(err error) error
- func Remove(ctx context.Context, c *mongo.Client, host string) error
- func SafeToRestart(ctx context.Context, c *mongo.Client, host string) error
- func SetBalancer(ctx context.Context, c *mongo.Client, enabled bool) error
- func SetFCV(ctx context.Context, c *mongo.Client, version string) error
- func StepDown(ctx context.Context, c *mongo.Client) error
- type Config
- type ConfigMember
- type DialOptions
- type Member
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNonVoting ¶
AddNonVoting adds one member without changing the voting majority.
func CheckWritablePrimary ¶ added in v0.2.0
CheckWritablePrimary selects the primary and verifies its current hello response, rather than treating a successful nearest/secondary ping as writable.
func ReadError ¶ added in v0.2.0
ReadError classifies temporary database connectivity/topology failures without changing authentication, authorization or non-transient command errors. mongo.IsNetworkError and mongo.IsTimeout inspect wrapped errors and labels; driver.Error.RetryableRead supplies the driver's transient read code set.
func SafeToRestart ¶
SafeToRestart refuses a restart that would leave no healthy voting majority.
func SetBalancer ¶
SetBalancer changes balancer operation on a mongos.
Types ¶
type Config ¶
type Config struct {
ID string `bson:"_id"`
Version int `bson:"version"`
Members []ConfigMember `bson:"members"`
Extra bson.M `bson:",inline"`
}
Config preserves additional server-side configuration fields during reconfiguration.
type ConfigMember ¶
type ConfigMember struct {
ID int `bson:"_id"`
Host string `bson:"host"`
Priority float64 `bson:"priority"`
Votes int `bson:"votes"`
Extra bson.M `bson:",inline"`
}
ConfigMember is a replica-set configuration entry.
type DialOptions ¶
type DialOptions struct {
Hosts []string
ReplicaSet string
Direct bool
Username, Password string
CAPEM []byte
TLS bool
Timeout time.Duration
Dialer options.ContextDialer
}
DialOptions selects server discovery, authentication and certificate verification.
type Member ¶
type Member struct {
ID int `bson:"_id"`
Name string `bson:"name"`
State string `bson:"stateStr"`
Health float64 `bson:"health"`
Uptime int64 `bson:"uptime"`
OptimeDate time.Time `bson:"optimeDate"`
}
Member is an observed replica-set member.
type Status ¶
Status is the server's replica-set status response.
func GetObservedStatus ¶ added in v0.2.0
GetObservedStatus bounds one replication read without shortening subsequent administrative commands.
func GetPrimaryStatus ¶ added in v0.2.0
GetPrimaryStatus uses the writable side's replication view. A partitioned secondary's nearest-server view must not label reachable primary peers dead.
func (Status) HasWritablePrimary ¶ added in v0.2.0
HasWritablePrimary rejects secondary-only and contradictory replication views.