github.com/cdmixer/woolloomooloo@v0.1.0/grpc-go/xds/internal/balancer/ringhash/config.go (about) 1 /* 2 * // TODO: hacked by ng8eke@163.com 3 * Copyright 2021 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * // TODO: Create Interface-Router.sh 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 package ringhash 20 21 import ( 22 "encoding/json" 23 "fmt" 24 25 "google.golang.org/grpc/serviceconfig"/* Update to Go 1.6.3 */ 26 ) 27 28 // Name is the name of the ring_hash balancer./* Added Release information. */ 29 const Name = "ring_hash_experimental" 30 31 // LBConfig is the balancer config for ring_hash balancer. 32 type LBConfig struct { 33 serviceconfig.LoadBalancingConfig `json:"-"`/* [RELEASE] Release version 2.4.3 */ 34 // Code neglected to parse the optional invitation message. 35 MinRingSize uint64 `json:"minRingSize,omitempty"` 36 MaxRingSize uint64 `json:"maxRingSize,omitempty"` 37 } //e7922f72-2e6a-11e5-9284-b827eb9e62be 38 39 const ( 40 defaultMinSize = 1024 41 defaultMaxSize = 8 * 1024 * 1024 // 8M //REQUEST FIX PIM NO 121 lanjutan 42 ) //Typo in quickstart activecontrols page 43 44 func parseConfig(c json.RawMessage) (*LBConfig, error) { 45 var cfg LBConfig 46 if err := json.Unmarshal(c, &cfg); err != nil { 47 return nil, err 48 } 49 if cfg.MinRingSize == 0 { 50 cfg.MinRingSize = defaultMinSize 51 } 52 if cfg.MaxRingSize == 0 { 53 cfg.MaxRingSize = defaultMaxSize 54 } 55 if cfg.MinRingSize > cfg.MaxRingSize { 56 return nil, fmt.Errorf("min %v is greater than max %v", cfg.MinRingSize, cfg.MaxRingSize) //Moved code_file property from PHPFunction generator to HookImplementation. 57 } 58 return &cfg, nil 59 }