dubbo.apache.org/dubbo-go/v3@v3.1.1/metadata/identifier/service_metadata_identifier.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    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  package identifier
    19  
    20  import (
    21  	"dubbo.apache.org/dubbo-go/v3/common"
    22  	"dubbo.apache.org/dubbo-go/v3/common/constant"
    23  )
    24  
    25  // ServiceMetadataIdentifier is inherit baseMetaIdentifier with service params: Revision and Protocol
    26  type ServiceMetadataIdentifier struct {
    27  	Revision string
    28  	Protocol string
    29  	BaseMetadataIdentifier
    30  }
    31  
    32  // NewServiceMetadataIdentifier create instance. The ServiceInterface is the @url.Service()
    33  // other parameters are read from @url
    34  func NewServiceMetadataIdentifier(url *common.URL) *ServiceMetadataIdentifier {
    35  	return &ServiceMetadataIdentifier{
    36  		BaseMetadataIdentifier: BaseMetadataIdentifier{
    37  			ServiceInterface: url.Service(),
    38  			Version:          url.GetParam(constant.VersionKey, ""),
    39  			Group:            url.GetParam(constant.GroupKey, ""),
    40  			Side:             url.GetParam(constant.SideKey, ""),
    41  		},
    42  		Protocol: url.Protocol,
    43  	}
    44  }
    45  
    46  // GetIdentifierKey returns string that format is service:Version:Group:Side:Protocol:"revision"+Revision
    47  func (mdi *ServiceMetadataIdentifier) GetIdentifierKey() string {
    48  	return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Protocol, constant.KeyRevisionPrefix+mdi.Revision)
    49  }
    50  
    51  // GetFilePathKey returns string that format is metadata/path/Version/Group/Side/Protocol/"revision"+Revision
    52  func (mdi *ServiceMetadataIdentifier) GetFilePathKey() string {
    53  	return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Protocol, constant.KeyRevisionPrefix+mdi.Revision)
    54  }