Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize annotation #814

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/dns_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type DNSDiscovery struct {
stopCh chan struct{}
}

// NewPeer2PeerDiscovery returns a new Peer2PeerDiscovery.
// NewDNSDiscovery returns a new DNSDiscovery.
func NewDNSDiscovery(domain string, network string, port int, d time.Duration) (*DNSDiscovery, error) {
discovery := &DNSDiscovery{domain: domain, network: network, port: port, d: d}
discovery.lookup()
Expand Down
2 changes: 1 addition & 1 deletion client/geo_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math"
)

//https://gist.github.com/cdipaolo/d3f8db3848278b49db68
// https://gist.github.com/cdipaolo/d3f8db3848278b49db68
func getDistanceFrom(lat1, lon1, lat2, lon2 float64) float64 {
var la1, lo1, la2, lo2, r float64
la1 = lat1 * math.Pi / 180
Expand Down
22 changes: 11 additions & 11 deletions client/mode.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package client

//FailMode decides how clients action when clients fail to invoke services
// FailMode decides how clients action when clients fail to invoke services
type FailMode int

const (
//Failover selects another server automaticaly
// Failover selects another server automaticaly
Failover FailMode = iota
//Failfast returns error immediately
// Failfast returns error immediately
Failfast
//Failtry use current client again
// Failtry use current client again
Failtry
//Failbackup select another server if the first server doesn't respond in specified time and use the fast response.
// Failbackup select another server if the first server doesn't respond in specified time and use the fast response.
Failbackup
)

// SelectMode defines the algorithm of selecting a services from candidates.
type SelectMode int

const (
//RandomSelect is selecting randomly
// RandomSelect is selecting randomly
RandomSelect SelectMode = iota
//RoundRobin is selecting by round robin
// RoundRobin is selecting by round robin
RoundRobin
//WeightedRoundRobin is selecting by weighted round robin
// WeightedRoundRobin is selecting by weighted round robin
WeightedRoundRobin
//WeightedICMP is selecting by weighted Ping time
// WeightedICMP is selecting by weighted Ping time
WeightedICMP
//ConsistentHash is selecting by hashing
// ConsistentHash is selecting by hashing
ConsistentHash
//Closest is selecting the closest server
// Closest is selecting the closest server
Closest

// SelectByUser is selecting by implementation of users
Expand Down
2 changes: 1 addition & 1 deletion client/ping_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func createICMPWeighted(servers map[string]string) []*Weighted {

// Ping gets network traffic by ICMP
func Ping(host string) (rtt int, err error) {
rtt = 1000 //default and timeout is 1000 ms
rtt = 1000 // default and timeout is 1000 ms

pinger, err := ping.NewPinger(host)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions client/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (p *pluginContainer) DoConnCreated(conn net.Conn) (net.Conn, error) {
return conn, nil
}

// DoConnCreated is called in case of client connection created.
// DoConnCreateFailed is called in case of client connection create failed.
func (p *pluginContainer) DoConnCreateFailed(network, address string) {
for i := range p.plugins {
if plugin, ok := p.plugins[i].(ConnCreateFailedPlugin); ok {
Expand All @@ -109,7 +109,7 @@ func (p *pluginContainer) DoClientConnected(conn net.Conn) (net.Conn, error) {
return conn, nil
}

// DoClientConnected is called in case of connected.
// DoClientConnectionClose is called in case of connection close.
func (p *pluginContainer) DoClientConnectionClose(conn net.Conn) error {
var err error
for i := range p.plugins {
Expand Down Expand Up @@ -137,7 +137,7 @@ func (p *pluginContainer) DoClientBeforeEncode(req *protocol.Message) error {
return nil
}

// DoClientBeforeEncode is called when requests are encoded and sent.
// DoClientAfterDecode is called when requests are decoded and received.
func (p *pluginContainer) DoClientAfterDecode(req *protocol.Message) error {
var err error
for i := range p.plugins {
Expand Down
4 changes: 2 additions & 2 deletions client/smooth_weighted_round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Weighted struct {
// }
// }

//https://github.com/phusion/nginx/commit/27e94984486058d73157038f7950a0a36ecc6e35
// https://github.com/phusion/nginx/commit/27e94984486058d73157038f7950a0a36ecc6e35
func nextWeighted(servers []*Weighted) (best *Weighted) {
total := 0

Expand All @@ -25,7 +25,7 @@ func nextWeighted(servers []*Weighted) (best *Weighted) {
if w == nil {
continue
}
//if w is down, continue
// if w is down, continue

w.CurrentWeight += w.EffectiveWeight
total += w.EffectiveWeight
Expand Down
2 changes: 1 addition & 1 deletion server/jsonrpc2_wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
CodeUnknownJSONRPCError = -32001
// CodeParseJSONRPCError is used when invalid JSON was received by the server.
CodeParseJSONRPCError = -32700
//CodeInvalidjsonrpcRequest is used when the JSON sent is not a valid jsonrpcRequest object.
// CodeInvalidjsonrpcRequest is used when the JSON sent is not a valid jsonrpcRequest object.
CodeInvalidjsonrpcRequest = -32600
// CodeMethodNotFound should be returned by the handler when the method does
// not exist / is not available.
Expand Down
2 changes: 1 addition & 1 deletion server/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewStreamService(addr string, streamHandler StreamHandler, acceptor StreamA
return fi
}

// EnableFileTransfer supports filetransfer service in this server.
// EnableStreamService supports stream service in this server.
func (s *Server) EnableStreamService(serviceName string, streamService *StreamService) {
if serviceName == "" {
serviceName = share.StreamServiceName
Expand Down
2 changes: 1 addition & 1 deletion serverplugin/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type aliasPair struct {
servicePath, serviceMethod string
}

//AliasPlugin can be used to set aliases for services
// AliasPlugin can be used to set aliases for services
type AliasPlugin struct {
Aliases map[string]*aliasPair
ReseverseAliases map[string]*aliasPair
Expand Down
2 changes: 1 addition & 1 deletion serverplugin/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (p *MDNSRegisterPlugin) Start() error {
extra["connections"] = fmt.Sprintf("%.2f", metrics.GetOrRegisterMeter("connections", p.Metrics).RateMean())
}

//set this same metrics for all services at this server
// set this same metrics for all services at this server
for _, sm := range p.Services {
v, _ := url.ParseQuery(string(sm.Meta))
for key, value := range extra {
Expand Down
12 changes: 5 additions & 7 deletions serverplugin/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type MetricsPlugin struct {
Prefix string
}

//NewMetricsPlugin creates a new MetricsPlugirn
// NewMetricsPlugin creates a new MetricsPlugin
func NewMetricsPlugin(registry metrics.Registry) *MetricsPlugin {
return &MetricsPlugin{Registry: registry}
}
Expand Down Expand Up @@ -78,8 +78,8 @@ func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, req *protocol.Mes

if t > 0 {
t = time.Now().UnixNano() - t
if t < 30*time.Minute.Nanoseconds() { //it is impossible that calltime exceeds 30 minute
//Historgram
if t < 30*time.Minute.Nanoseconds() { // it is impossible that calltime exceeds 30 minute
// Historgram
h := metrics.GetOrRegisterHistogram(p.withPrefix("service."+sp+"."+sm+".CallTime"), p.Registry,
metrics.NewExpDecaySample(1028, 0.015))
h.Update(t)
Expand All @@ -91,16 +91,14 @@ func (p *MetricsPlugin) PostWriteResponse(ctx context.Context, req *protocol.Mes
// Log reports metrics into logs.
//
// p.Log( 5 * time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
//
func (p *MetricsPlugin) Log(freq time.Duration, l metrics.Logger) {
go metrics.Log(p.Registry, freq, l)
}

// Graphite reports metrics into graphite.
//
// addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
// p.Graphite(10e9, "metrics", addr)
//
// addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
// p.Graphite(10e9, "metrics", addr)
func (p *MetricsPlugin) Graphite(freq time.Duration, prefix string, addr *net.TCPAddr) {
go metrics.Graphite(p.Registry, freq, prefix, addr)
}
Expand Down
2 changes: 1 addition & 1 deletion serverplugin/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p *RedisRegisterPlugin) Start() error {
extra["calls"] = fmt.Sprintf("%.2f", metrics.GetOrRegisterMeter("calls", p.Metrics).RateMean())
extra["connections"] = fmt.Sprintf("%.2f", metrics.GetOrRegisterMeter("connections", p.Metrics).RateMean())
}
//set this same metrics for all services at this server
// set this same metrics for all services at this server
for _, name := range p.Services {
nodePath := fmt.Sprintf("%s/%s/%s", p.BasePath, name, p.ServiceAddress)
kvPair, err := p.kv.Get(nodePath)
Expand Down
2 changes: 1 addition & 1 deletion serverplugin/req_rate_limiting_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewRedisRateLimitingPlugin(addrs []string, rate int, burst int, period time
}
}

// PreReadRequest can limit request processing.
// PostReadRequest can limit request processing.
func (plugin *RedisRateLimitingPlugin) PostReadRequest(ctx context.Context, r *protocol.Message, e error) error {
res, err := plugin.limiter.Allow(ctx, r.ServicePath+"/"+r.ServiceMethod, plugin.limit)
if err != nil {
Expand Down
Loading