文件名称:重试::recycling_symbol_selector:最先进的可中断机制,可重复执行操作直到成功
文件大小:1.17MB
文件格式:ZIP
更新时间:2024-02-23 11:00:12
go library module repeat jitter
:recycling_symbol_selector: 重试 最先进的可中断机制,可重复执行操作直到成功。 :light_bulb: 理念 重试基于但经过完全重做,并专注于与 :construction: 和内置包。 ctx , cancel := context . WithTimeout ( context . Background (), time . Minute ) defer cancel () action := func ( ctx context. Context ) ( err error ) { req := req . Clone ( ctx ) resp , err = http . DefaultClient . Do ( req ) return err } how := []retry. How { strategy . Limit ( 5 ), strategy . BackoffWithJitter ( backoff . Fibonacci ( 10 * time . Millisecond ), jitter . Norm