Documentation ¶
Index ¶
- Constants
- Variables
- type Dispatcher
- func (dispatch *Dispatcher) GetDeadLine() int64
- func (dispatch *Dispatcher) GetDeadLineWithString() string
- func (dispathch *Dispatcher) GetLimit() int
- func (dispatch *Dispatcher) GetSHAScript(index string) string
- func (dispatch *Dispatcher) MiddleWare(command string, limit int) gin.HandlerFunc
- func (dispatch *Dispatcher) ParseCommand(command string) (time.Duration, error)
- func (dispatch *Dispatcher) UpdateDeadLine()
Constants ¶
View Source
const ResetScript = `` /* 286-byte string literal not displayed */
View Source
const Script = `` /* 1902-byte string literal not displayed */
View Source
const TimeFormat = "2006-01-02 15:04:05"
for the deadline time format.
Variables ¶
View Source
var ( LimitError = errors.New("Limit should > 0.") CommandError = errors.New("The command of first number should > 0.") FormatError = errors.New("Please check the format with your input.") MethodError = errors.New("Please check the method is one of http method.") ServerError = errors.New("StatusInternalServerError, please wait a minute.") )
self define error
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func LimitDispatcher ¶
func LimitDispatcher(command string, limit int, rdb *redis.Client) (*Dispatcher, error)
create a limit dispatcher object with command and limit request number.
func (*Dispatcher) GetDeadLine ¶
func (dispatch *Dispatcher) GetDeadLine() int64
get the deadline with unix time.
func (*Dispatcher) GetDeadLineWithString ¶
func (dispatch *Dispatcher) GetDeadLineWithString() string
get the deadline with format 2006-01-02 15:04:05
func (*Dispatcher) GetSHAScript ¶
func (dispatch *Dispatcher) GetSHAScript(index string) string
func (*Dispatcher) MiddleWare ¶
func (dispatch *Dispatcher) MiddleWare(command string, limit int) gin.HandlerFunc
func (*Dispatcher) ParseCommand ¶
func (dispatch *Dispatcher) ParseCommand(command string) (time.Duration, error)
func (*Dispatcher) UpdateDeadLine ¶
func (dispatch *Dispatcher) UpdateDeadLine()
update the deadline
Click to show internal directories.
Click to hide internal directories.