github.com/therealbill/libredis@v0.0.0-20161227004305-7d50abda5ccf/structures/sentinel.go (about)

     1  package structures
     2  
     3  import "time"
     4  
     5  type Sentinel struct {
     6  	Address        string
     7  	LastConnection time.Time
     8  }
     9  
    10  type SentinelList []Sentinel
    11  
    12  // MasterAddress is a small struct to provide connection information for a
    13  // Master as returned from get-master-addr-by-name
    14  type MasterAddress struct {
    15  	Host string
    16  	Port int
    17  }
    18  
    19  // MasterInfo is a struct providing the information available from sentinel
    20  // about a given master (aka pod)
    21  // The way this works is you tag the field with the name redis returns
    22  // and reflect is used in the methods which return this structure to populate
    23  // it with the data from Redis
    24  //
    25  // Note this means it will nee dto be updated when new fields are added in
    26  // sentinel. Fortunately this appears to be rare.
    27  //
    28  // Currently the list is:
    29  // 'pending-commands'
    30  // 'ip'
    31  // 'down-after-milliseconds'
    32  // 'role-reported'
    33  // 'runid'
    34  // 'port'
    35  // 'last-ok-ping-reply'
    36  // 'last-ping-sent'
    37  // 'failover-timeout'
    38  // 'config-epoch'
    39  // 'quorum'
    40  // 'role-reported-time'
    41  // 'last-ping-reply'
    42  // 'name'
    43  // 'parallel-syncs'
    44  // 'info-refresh'
    45  // 'flags'
    46  // 'num-slaves'
    47  // 'num-other-sentinels'
    48  type MasterInfo struct {
    49  	Name                  string `redis:"name"`
    50  	Port                  int    `redis:"port"`
    51  	NumSlaves             int    `redis:"num-slaves"`
    52  	Quorum                int    `redis:"quorum"`
    53  	NumOtherSentinels     int    `redis:"num-other-sentinels"`
    54  	ParallelSyncs         int    `redis:"parallel-syncs"`
    55  	Runid                 string `redis:"runid"`
    56  	IP                    string `redis:"ip"`
    57  	DownAfterMilliseconds int    `redis:"down-after-milliseconds"`
    58  	IsMasterDown          bool   `redis:"is-master-down"`
    59  	LastOkPingReply       int    `redis:"last-ok-ping-reply"`
    60  	RoleReportedTime      int    `redis:"role-reported-time"`
    61  	InfoRefresh           int    `redis:"info-refresh"`
    62  	RoleReported          string `redis:"role-reported"`
    63  	LastPingReply         int    `redis:"last-ping-reply"`
    64  	LastPingSent          int    `redis:"last-ping-sent"`
    65  	FailoverTimeout       int    `redis:"failover-timeout"`
    66  	ConfigEpoch           int    `redis:"config-epoch"`
    67  	Flags                 string `redis:"flags"`
    68  }
    69  
    70  // SlaveInfo is a struct for the results returned from slave queries,
    71  // specifically the individual entries of the  `sentinel slave <podname>`
    72  // command. As with the other Sentinel structs this may change and will need
    73  // updated for new entries
    74  // Currently the members defined by sentinel are as follows.
    75  // "name"
    76  // "ip"
    77  // "port"
    78  // "runid"
    79  // "flags"
    80  // "pending-commands"
    81  // "last-ping-sent"
    82  // "last-ok-ping-reply"
    83  // "last-ping-reply"
    84  // "down-after-milliseconds"
    85  // "info-refresh"
    86  // "role-reported"
    87  // "role-reported-time"
    88  // "master-link-down-time"
    89  // "master-link-status"
    90  // "master-host"
    91  // "master-port"
    92  // "slave-priority"
    93  // "slave-repl-offset"
    94  type SlaveInfo struct {
    95  	Name                   string `redis:"name"`
    96  	Host                   string `redis:"ip"`
    97  	Port                   int    `redis:"port"`
    98  	Runid                  string `redis:"runid"`
    99  	Flags                  string `redis:"flags"`
   100  	PendingCommands        int    `redis:"pending-commands"`
   101  	IsMasterDown           bool   `redis:"is-master-down"`
   102  	LastOkPingReply        int    `redis:"last-ok-ping-reply"`
   103  	RoleReportedTime       int    `redis:"role-reported-time"`
   104  	LastPingReply          int    `redis:"last-ping-reply"`
   105  	LastPingSent           int    `redis:"last-ping-sent"`
   106  	InfoRefresh            int    `redis:"info-refresh"`
   107  	RoleReported           string `redis:"role-reported"`
   108  	MasterLinkDownTime     int    `redis:"master-link-down-time"`
   109  	MasterLinkStatus       string `redis:"master-link-status"`
   110  	MasterHost             string `redis:"master-host"`
   111  	MasterPort             int    `redis:"master-port"`
   112  	SlavePriority          int    `redis:"slave-priority"`
   113  	SlaveReplicationOffset int    `redis:"slave-repl-offset"`
   114  }
   115  
   116  // SentinelInfo represents the information returned from a "SENTINEL SENTINELS
   117  // <name>" command
   118  type SentinelInfo struct {
   119  	Name                  string `redis:"name"`
   120  	IP                    string `redis:"ip"`
   121  	Port                  int    `redis:"port"`
   122  	Runid                 string `redis:"runid"`
   123  	Flags                 string `redis:"flags"`
   124  	PendingCommands       int    `redis:"pending-commands"`
   125  	LastPingReply         int    `redis:"last-ping-reply"`
   126  	LastPingSent          int    `redis:"last-ping-sent"`
   127  	LastOkPingReply       int    `redis:"last-ok-ping-reply"`
   128  	DownAfterMilliseconds int    `redis:"down-after-milliseconds"`
   129  	LastHelloMessage      int    `redis:"last-hello-message"`
   130  	VotedLeader           string `redis:"voted-leader"`
   131  	VotedLeaderEpoch      int    `redis:"voted-leader-epoch"`
   132  }