mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-08-24 06:38:42 +08:00
Add completed state
This commit is contained in:
@@ -27,6 +27,7 @@ var (
|
||||
flagRedisInsecureTLS bool
|
||||
flagRedisClusterNodes string
|
||||
flagMaxPayloadLength int
|
||||
flagMaxResultLength int
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -39,6 +40,7 @@ func init() {
|
||||
flag.BoolVar(&flagRedisInsecureTLS, "redis-insecure-tls", false, "disable TLS certificate host checks")
|
||||
flag.StringVar(&flagRedisClusterNodes, "redis-cluster-nodes", "", "comma separated list of host:port addresses of cluster nodes")
|
||||
flag.IntVar(&flagMaxPayloadLength, "max-payload-length", 200, "maximum number of utf8 characters printed in the payload cell in the Web UI")
|
||||
flag.IntVar(&flagMaxResultLength, "max-result-length", 200, "maximum number of utf8 characters printed in the result cell in the Web UI")
|
||||
}
|
||||
|
||||
// TODO: Write test and refactor this code.
|
||||
@@ -102,6 +104,7 @@ func main() {
|
||||
h := asynqmon.New(asynqmon.Options{
|
||||
RedisConnOpt: redisConnOpt,
|
||||
PayloadFormatter: asynqmon.PayloadFormatterFunc(formatPayload),
|
||||
ResultFormatter: asynqmon.ResultFormatterFunc(formatResult),
|
||||
})
|
||||
defer h.Close()
|
||||
|
||||
@@ -125,6 +128,11 @@ func formatPayload(taskType string, payload []byte) string {
|
||||
return truncate(payloadStr, flagMaxPayloadLength)
|
||||
}
|
||||
|
||||
func formatResult(taskType string, result []byte) string {
|
||||
resultStr := asynqmon.DefaultResultFormatter.FormatResult(taskType, result)
|
||||
return truncate(resultStr, flagMaxResultLength)
|
||||
}
|
||||
|
||||
// truncates string s to limit length (in utf8).
|
||||
func truncate(s string, limit int) string {
|
||||
i := 0
|
||||
|
Reference in New Issue
Block a user