git.zd.zone/hrpc/hrpc@v0.0.12/database/mongodb/option.go (about)

     1  package mongodb
     2  
     3  type Options struct {
     4  	Address  string `json:"address"`
     5  	Username string `json:"username"`
     6  	Password string `json:"password"`
     7  
     8  	// customized
     9  	customized bool
    10  }
    11  
    12  type Option func(o *Options)
    13  
    14  // WithCustomized will use your own configurations.
    15  // To be reminder that you should make sure the values of Address, Auth, Port have been assigned correctly.
    16  func WithCustomized() Option {
    17  	return func(o *Options) {
    18  		o.customized = true
    19  	}
    20  }
    21  
    22  func WithAddress(s string) Option {
    23  	return func(o *Options) {
    24  		o.Address = s
    25  	}
    26  }
    27  
    28  func WithAuth(username, password string) Option {
    29  	return func(o *Options) {
    30  		o.Username = username
    31  		o.Password = password
    32  	}
    33  }