util

package
v1.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accessible

func Accessible(ctx context.Context, consumerID string, providerID string) *scerr.Error

func AddDependencyRule

func AddDependencyRule(ctx context.Context, dep *Dependency) error

func AddServiceVersionRule

func AddServiceVersionRule(ctx context.Context, domainProject string, consumer *pb.MicroService, provider *pb.MicroServiceKey) error

func AddTagIntoETCD

func AddTagIntoETCD(ctx context.Context, domainProject string, serviceID string, dataTags map[string]string) *scerr.Error

func AllowAcrossDimension

func AllowAcrossDimension(ctx context.Context, providerService *pb.MicroService, consumerService *pb.MicroService) error

func AppendFindResponse

func AppendFindResponse(ctx context.Context, index int64, resp *pb.Response, instances []*pb.MicroServiceInstance,
	updatedResult *[]*pb.FindResult, notModifiedResult *[]int64, failedResult **pb.FindFailedResult)

func AtLess

func AtLess(sorted []string, kvs map[string]*discovery.KeyValue, start, end string) []string

func BadParamsResponse

func BadParamsResponse(detailErr string) *pb.CreateDependenciesResponse

func CheckSchemaInfoExist

func CheckSchemaInfoExist(ctx context.Context, key string) (bool, error)

func CleanUpDependencyRules

func CleanUpDependencyRules(ctx context.Context, domainProject string) error

func CreateDependencyRule

func CreateDependencyRule(ctx context.Context, dep *Dependency) error

func DeleteDependencyForDeleteService

func DeleteDependencyForDeleteService(domainProject string, serviceID string, service *pb.MicroServiceKey) (registry.PluginOp, error)

func DeleteServiceAllInstances

func DeleteServiceAllInstances(ctx context.Context, serviceID string) error

func DependencyRuleExist

func DependencyRuleExist(ctx context.Context, provider *pb.MicroServiceKey, consumer *pb.MicroServiceKey) (bool, error)

func DomainExist

func DomainExist(ctx context.Context, domain string) (bool, error)

func FindServiceIds

func FindServiceIds(ctx context.Context, versionRule string, key *pb.MicroServiceKey) ([]string, bool, error)

func FormatRevision

func FormatRevision(revs, counts []int64) (s string)

func FromContext

func FromContext(ctx context.Context) []registry.PluginOpOption

func GetAllConsumerIds

func GetAllConsumerIds(ctx context.Context, domainProject string, provider *pb.MicroService) (allow []string, deny []string, _ error)

GetAllConsumerIds is the function get from dependency rule and filter with service rules

func GetAllDomain

func GetAllDomain(ctx context.Context) ([]string, error)

func GetAllDomainRawData

func GetAllDomainRawData(ctx context.Context) ([]*discovery.KeyValue, error)

func GetAllProviderIds

func GetAllProviderIds(ctx context.Context, domainProject string, service *pb.MicroService) (allow []string, deny []string, _ error)

func GetAllServiceUtil

func GetAllServiceUtil(ctx context.Context) ([]*pb.MicroService, error)

func GetAllServicesAcrossDomainProject

func GetAllServicesAcrossDomainProject(ctx context.Context) (map[string][]*pb.MicroService, error)

GetAllServicesAcrossDomainProject get services of all domains, projects the map's key is domainProject

func GetConsumerIds

func GetConsumerIds(ctx context.Context, domainProject string, provider *pb.MicroService) ([]string, error)

func GetInstance

func GetInstance(ctx context.Context, domainProject string, serviceID string, instanceID string) (*pb.MicroServiceInstance, error)

func GetInstanceCountOfOneService

func GetInstanceCountOfOneService(ctx context.Context, domainProject string, serviceID string) (int64, error)

func GetInstancesWithoutProperties added in v1.4.8

func GetInstancesWithoutProperties(ctx context.Context, domainProject string, serviceID string) ([]*pb.MicroServiceInstance, error)

func GetLeaseID

func GetLeaseID(ctx context.Context, domainProject string, serviceID string, instanceID string) (int64, error)

func GetOneDomainProjectInstanceCount

func GetOneDomainProjectInstanceCount(ctx context.Context, domainProject string) (int64, error)

func GetOneDomainProjectServiceCount

func GetOneDomainProjectServiceCount(ctx context.Context, domainProject string) (int64, error)

func GetOneRule

func GetOneRule(ctx context.Context, domainProject, serviceID, ruleID string) (*pb.ServiceRule, error)

func GetProviderIds

func GetProviderIds(ctx context.Context, domainProject string, consumer *pb.MicroService) ([]string, error)

func GetRulesUtil

func GetRulesUtil(ctx context.Context, domainProject string, serviceID string) ([]*pb.ServiceRule, error)

func GetService

func GetService(ctx context.Context, domainProject string, serviceID string) (*pb.MicroService, error)

func GetServiceAllVersions

func GetServiceAllVersions(ctx context.Context, key *pb.MicroServiceKey, alias bool) (*discovery.Response, error)

func GetServiceFromCache

func GetServiceFromCache(domainProject string, serviceID string) *pb.MicroService

GetServiceFromCache gets service from cache

func GetServiceID

func GetServiceID(ctx context.Context, key *pb.MicroServiceKey) (serviceID string, err error)

func GetServiceRuleType

func GetServiceRuleType(ctx context.Context, domainProject string, serviceID string) (string, int, error)

func GetServiceWithRev

func GetServiceWithRev(ctx context.Context, domain string, id string, rev int64) (*pb.MicroService, error)

get Service by service id

func GetServicesByDomainProject

func GetServicesByDomainProject(ctx context.Context, domainProject string) ([]*pb.MicroService, error)

func GetTagsUtils

func GetTagsUtils(ctx context.Context, domainProject, serviceID string) (tags map[string]string, err error)

func HeartbeatUtil

func HeartbeatUtil(ctx context.Context, domainProject string, serviceID string, instanceID string) (leaseID int64, ttl int64, _ *scerr.Error)

func KeepAliveLease

func KeepAliveLease(ctx context.Context, domainProject, serviceID, instanceID string, leaseID int64) (ttl int64, err error)

func Larger

func Larger(start, end string) bool

func Latest

func Latest(sorted []string, kvs map[string]*discovery.KeyValue, start, end string) []string

func LessEqual

func LessEqual(start, end string) bool

func MatchRules

func MatchRules(rulesOfProvider []*pb.ServiceRule, consumer *pb.MicroService, tagsOfConsumer map[string]string) *scerr.Error

func NewDomain

func NewDomain(ctx context.Context, domain string) (bool, error)

func NewDomainProject

func NewDomainProject(ctx context.Context, domain, project string) error

func NewProject

func NewProject(ctx context.Context, domain, project string) (bool, error)

func ParamsChecker

func ParamsChecker(consumerInfo *pb.MicroServiceKey, providersInfo []*pb.MicroServiceKey) *pb.CreateDependenciesResponse

func ParseVersionRule

func ParseVersionRule(versionRule string) func(kvs []*discovery.KeyValue) []string

func ProjectExist

func ProjectExist(ctx context.Context, domain, project string) (bool, error)

func QueryAllProvidersInstances

func QueryAllProvidersInstances(ctx context.Context, selfServiceID string) (results []*pb.WatchInstanceResponse, rev int64)

func Range

func Range(sorted []string, kvs map[string]*discovery.KeyValue, start, end string) []string

func RemandInstanceQuota

func RemandInstanceQuota(ctx context.Context)

func RemandServiceQuota

func RemandServiceQuota(ctx context.Context)

func RuleExist

func RuleExist(ctx context.Context, domainProject string, serviceID string, attr string, pattern string) bool

func ServiceExist

func ServiceExist(ctx context.Context, domainProject string, serviceID string) bool

func SetServiceDefaultValue

func SetServiceDefaultValue(service *pb.MicroService)

func TransferToMicroServiceDependency

func TransferToMicroServiceDependency(ctx context.Context, key string) (*pb.MicroServiceDependency, error)

func UpdateInstance

func UpdateInstance(ctx context.Context, domainProject string, instance *pb.MicroServiceInstance) *scerr.Error

func UpdateService

func UpdateService(domainProject string, serviceID string, service *pb.MicroService) (opt registry.PluginOp, err error)

func VersionMatchRule

func VersionMatchRule(version string, versionRule string) bool

func VersionToInt64

func VersionToInt64(versionStr string) (ret int64, err error)

Types

type Dependency

type Dependency struct {
	DomainProject string
	// store the consumer Dependency from dep-queue object
	Consumer      *rmodel.MicroServiceKey
	ProvidersRule []*rmodel.MicroServiceKey
	// store the parsed rules from Dependency object
	DeleteDependencyRuleList []*rmodel.MicroServiceKey
	CreateDependencyRuleList []*rmodel.MicroServiceKey
}

func (*Dependency) Commit

func (dep *Dependency) Commit(ctx context.Context) error

type DependencyRelation

type DependencyRelation struct {
	// contains filtered or unexported fields
}

func NewConsumerDependencyRelation

func NewConsumerDependencyRelation(ctx context.Context, domainProject string, consumer *pb.MicroService) *DependencyRelation

func NewDependencyRelation

func NewDependencyRelation(ctx context.Context, domainProject string, consumer *pb.MicroService, provider *pb.MicroService) *DependencyRelation

func NewProviderDependencyRelation

func NewProviderDependencyRelation(ctx context.Context, domainProject string, provider *pb.MicroService) *DependencyRelation

func (*DependencyRelation) GetDependencyConsumerIds

func (dr *DependencyRelation) GetDependencyConsumerIds() ([]string, error)

func (*DependencyRelation) GetDependencyConsumers

func (dr *DependencyRelation) GetDependencyConsumers(opts ...DependencyRelationFilterOption) ([]*pb.MicroService, error)

func (*DependencyRelation) GetDependencyProviderIds

func (dr *DependencyRelation) GetDependencyProviderIds() ([]string, error)

func (*DependencyRelation) GetDependencyProviders

func (dr *DependencyRelation) GetDependencyProviders(opts ...DependencyRelationFilterOption) ([]*pb.MicroService, error)

type DependencyRelationFilterOpt

type DependencyRelationFilterOpt struct {
	SameDomainProject bool
	NonSelf           bool
}

type DependencyRelationFilterOption

type DependencyRelationFilterOption func(opt DependencyRelationFilterOpt) DependencyRelationFilterOpt

func WithSameDomainProject

func WithSameDomainProject() DependencyRelationFilterOption

func WithoutSelfDependency

func WithoutSelfDependency() DependencyRelationFilterOption

type EndpointIndexValue

type EndpointIndexValue struct {
	// contains filtered or unexported fields
}

func ParseEndpointIndexValue

func ParseEndpointIndexValue(value []byte) EndpointIndexValue

type RuleFilter

type RuleFilter struct {
	DomainProject string
	ProviderRules []*pb.ServiceRule
}

func (*RuleFilter) Filter

func (rf *RuleFilter) Filter(ctx context.Context, consumerID string) (bool, error)

func (*RuleFilter) FilterAll

func (rf *RuleFilter) FilterAll(ctx context.Context, consumerIDs []string) (allow []string, deny []string, err error)

type VersionRegexp

type VersionRegexp struct {
	Regex *regexp.Regexp
	Fuzzy bool
}

func NewVersionRegexp

func NewVersionRegexp(fuzzy bool) (vr *VersionRegexp)

func (*VersionRegexp) MatchString

func (vr *VersionRegexp) MatchString(s string) bool

func (*VersionRegexp) String

func (vr *VersionRegexp) String() string

type VersionRule

type VersionRule func(sorted []string, kvs map[string]*discovery.KeyValue, start, end string) []string

func (VersionRule) Match

func (vr VersionRule) Match(kvs []*discovery.KeyValue, ops ...string) []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL