@@ -344,10 +344,6 @@ const (
344344
345345type Scheme string
346346
347- const (
348- SchemeHTTP = "http"
349- )
350-
351347type UpstreamType string
352348
353349const (
@@ -519,11 +515,13 @@ func ComposeServiceNameWithRule(namespace, name string, rule string) string {
519515 return buf .String ()
520516}
521517
522- func ComposeServiceNameWithStream (namespace , name string , rule string ) string {
523- // FIXME Use sync.Pool to reuse this buffer if the upstream
524- // name composing code path is hot.
518+ func ComposeGRPCServiceNameWithRule (namespace , name string , rule string ) string {
519+ return ComposeServicesNameWithScheme (namespace , name , rule , "grpc" )
520+ }
521+
522+ func ComposeServicesNameWithScheme (namespace , name string , rule string , scheme string ) string {
525523 var p []byte
526- plen := len (namespace ) + len (name ) + 6
524+ plen := len (namespace ) + len (name ) + len ( rule ) + len ( scheme ) + 3
527525
528526 p = make ([]byte , 0 , plen )
529527 buf := bytes .NewBuffer (p )
@@ -532,11 +530,16 @@ func ComposeServiceNameWithStream(namespace, name string, rule string) string {
532530 buf .WriteString (name )
533531 buf .WriteByte ('_' )
534532 buf .WriteString (rule )
535- buf .WriteString ("_stream" )
533+ buf .WriteByte ('_' )
534+ buf .WriteString (scheme )
536535
537536 return buf .String ()
538537}
539538
539+ func ComposeServiceNameWithStream (namespace , name string , rule string ) string {
540+ return ComposeServicesNameWithScheme (namespace , name , rule , "stream" )
541+ }
542+
540543func ComposeConsumerName (namespace , name string ) string {
541544 // FIXME Use sync.Pool to reuse this buffer if the upstream
542545 // name composing code path is hot.
@@ -569,9 +572,8 @@ func NewDefaultUpstream() *Upstream {
569572 "managed-by" : "apisix-ingress-controller" ,
570573 },
571574 },
572- Nodes : make (UpstreamNodes , 0 ),
573- Scheme : SchemeHTTP ,
574- Type : Roundrobin ,
575+ Nodes : make (UpstreamNodes , 0 ),
576+ Type : Roundrobin ,
575577 }
576578}
577579
0 commit comments