-
Exceptions with webclients are all wrapped in WebClientResponseException class. So we can handle that using Spring's ExceptionHandler annotation.
-
Using ExchangeFilterFunction while constructing the webclient bean.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hash 'string' to a small number (digits default: 6) | |
function hash(string, digits) { | |
digits = digits || 6; | |
var m = Math.pow(10, digits+1) - 1; | |
var phi = Math.pow(10, digits) / 2 - 1; | |
var n = 0; | |
for (var i = 0; i < string.length; i++) { | |
n = (n + phi * string.charCodeAt(i)) % m; | |
} | |
return n.toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"io" | |
"log" | |
"sync/atomic" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bufio" | |
"os" | |
"strconv" | |
) | |
func ReadLinesFromFile(file_path string) ([]string, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global: | |
scrape_interval: 10s | |
scrape_configs: | |
- job_name: node | |
static_configs: | |
- targets: | |
- localhost:9100 | |
- job_name: python-app | |
static_configs: | |
- targets: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (receiver *GoStatsImpl) LargestRemainderRpc(ctx context.Context, request *pb.PercentageReqVo) (*pb.LargestRemainderRpcResponse, error) { | |
var payload vo.PercentageReqVo | |
copier.DeepCopy(request, &payload) | |
data, err := receiver.LargestRemainder(ctx, payload) | |
if err != nil { | |
return nil, err | |
} | |
var ret pb.LargestRemainderRpcResponse | |
err = copier.DeepCopy(data, &ret.Data) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (receiver *GoStatsImpl) LargestRemainder(ctx context.Context, payload vo.PercentageReqVo) (data []vo.PercentageRespVo, err error) { | |
if len(payload.Data) == 0 { | |
return | |
} | |
input := make([]numberutils.Percentage, 0) | |
for _, item := range payload.Data { | |
input = append(input, numberutils.Percentage{ | |
Value: item.Value, | |
Data: item.Key, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generated by go-doudou v2.0.3. | |
* You can edit it as your need. | |
*/ | |
package service | |
import ( | |
"context" | |
"go-doudou-tutorials/go-stats/config" | |
pb "go-doudou-tutorials/go-stats/transport/grpc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generated by go-doudou v2.0.3. | |
* You can edit it as your need. | |
*/ | |
package service | |
import ( | |
"context" | |
"go-doudou-tutorials/go-stats/config" | |
pb "go-doudou-tutorials/go-stats/transport/grpc" |
NewerOlder