@@ -343,10 +343,6 @@ const (
343343
344344type Scheme string
345345
346- const (
347- SchemeHTTP = "http"
348- )
349-
350346type UpstreamType string
351347
352348const (
@@ -518,11 +514,13 @@ func ComposeServiceNameWithRule(namespace, name string, rule string) string {
518514 return buf .String ()
519515}
520516
521- func ComposeServiceNameWithStream (namespace , name string , rule string ) string {
522- // FIXME Use sync.Pool to reuse this buffer if the upstream
523- // name composing code path is hot.
517+ func ComposeGRPCServiceNameWithRule (namespace , name string , rule string ) string {
518+ return ComposeServicesNameWithScheme (namespace , name , rule , "grpc" )
519+ }
520+
521+ func ComposeServicesNameWithScheme (namespace , name string , rule string , scheme string ) string {
524522 var p []byte
525- plen := len (namespace ) + len (name ) + 6
523+ plen := len (namespace ) + len (name ) + len ( rule ) + len ( scheme ) + 3
526524
527525 p = make ([]byte , 0 , plen )
528526 buf := bytes .NewBuffer (p )
@@ -531,11 +529,16 @@ func ComposeServiceNameWithStream(namespace, name string, rule string) string {
531529 buf .WriteString (name )
532530 buf .WriteByte ('_' )
533531 buf .WriteString (rule )
534- buf .WriteString ("_stream" )
532+ buf .WriteByte ('_' )
533+ buf .WriteString (scheme )
535534
536535 return buf .String ()
537536}
538537
538+ func ComposeServiceNameWithStream (namespace , name string , rule string ) string {
539+ return ComposeServicesNameWithScheme (namespace , name , rule , "stream" )
540+ }
541+
539542func ComposeConsumerName (namespace , name string ) string {
540543 // FIXME Use sync.Pool to reuse this buffer if the upstream
541544 // name composing code path is hot.
@@ -568,9 +571,8 @@ func NewDefaultUpstream() *Upstream {
568571 "managed-by" : "apisix-ingress-controller" ,
569572 },
570573 },
571- Nodes : make (UpstreamNodes , 0 ),
572- Scheme : SchemeHTTP ,
573- Type : Roundrobin ,
574+ Nodes : make (UpstreamNodes , 0 ),
575+ Type : Roundrobin ,
574576 }
575577}
576578
0 commit comments