xds

package
v0.0.0-...-0c1943d Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package xds contains the implementation for the xds server cache updates

Index

Constants

This section is empty.

Variables

View Source
var (
	// APIListMap has the following mapping label -> apiUUID -> API (Metadata)
	APIListMap map[string]map[string]*subscription.APIs
	// SubscriptionMap contains the subscriptions recieved from API Manager Control Plane
	SubscriptionMap map[int32]*subscription.Subscription
	// ApplicationMap contains the applications recieved from API Manager Control Plane
	ApplicationMap map[string]*subscription.Application
	// ApplicationKeyMappingMap contains the application key mappings recieved from API Manager Control Plane
	ApplicationKeyMappingMap map[string]*subscription.ApplicationKeyMapping
	// ApplicationPolicyMap contains the application policies recieved from API Manager Control Plane
	ApplicationPolicyMap map[int32]*subscription.ApplicationPolicy
	// SubscriptionPolicyMap contains the subscription policies recieved from API Manager Control Plane
	SubscriptionPolicyMap map[int32]*subscription.SubscriptionPolicy
)
View Source
var (

	// KeyManagerList to store data
	KeyManagerList = make([]eventhubTypes.KeyManager, 0)
)
View Source
var (

	// RequestEventChannel is the channel which communicates between callback and the server
	RequestEventChannel chan RequestEvent
)

Functions

func CheckIfAPIMetadataIsAlreadyAvailable

func CheckIfAPIMetadataIsAlreadyAvailable(apiUUID, label string) bool

CheckIfAPIMetadataIsAlreadyAvailable returns true only if the API Metadata for the given API UUID is already available

func DeleteAPIAndReturnList

func DeleteAPIAndReturnList(apiUUID, organizationUUID string, gatewayLabel string) *subscription.APIList

DeleteAPIAndReturnList removes the API from internal maps and returns the marshalled API List. If the apiUUID is not found in the internal map under the provided environment, then it would return a nil value. Hence it is required to check if the return value is nil, prior to updating the XDS cache.

func DeleteAPIWithAPIMEvent

func DeleteAPIWithAPIMEvent(uuid, organizationID string, environments []string, revisionUUID string)

DeleteAPIWithAPIMEvent deletes API with the given UUID from the given gw environments

func DeleteAPIs

func DeleteAPIs(vhost, apiName, version string, environments []string, organizationID string) error

DeleteAPIs deletes an API, its resources and updates the caches of given environments

func DeleteAPIsWithUUID

func DeleteAPIsWithUUID(vhost, uuid string, environments []string, organizationID string) error

DeleteAPIsWithUUID deletes an API, its resources and updates the caches of given environments

func DeployReadinessAPI

func DeployReadinessAPI(envs []string)

DeployReadinessAPI Method to set the status after the last api is fected and updated in router.

func ExtractVhostFromAPIIdentifier

func ExtractVhostFromAPIIdentifier(id string) (string, error)

ExtractVhostFromAPIIdentifier extracts vhost from the API identifier

func GenerateAndUpdateKeyManagerList

func GenerateAndUpdateKeyManagerList()

GenerateAndUpdateKeyManagerList converts the data into KeyManager proto type

func GenerateEnvoyResoucesForLabel

func GenerateEnvoyResoucesForLabel(label string) ([]types.Resource, []types.Resource, []types.Resource,
	[]types.Resource, []types.Resource)

GenerateEnvoyResoucesForLabel generates envoy resources for a given label This method will list out all APIs mapped to the label. and generate envoy resources for all of these APIs.

func GenerateGlobalClusters

func GenerateGlobalClusters(label string)

GenerateGlobalClusters generates the globally available clusters and endpoints.

func GenerateHashedAPINameVersionIDWithoutVhost

func GenerateHashedAPINameVersionIDWithoutVhost(name, version string) string

GenerateHashedAPINameVersionIDWithoutVhost generates a hashed identifier unique to the API Name and Version

func GenerateIdentifierForAPI

func GenerateIdentifierForAPI(vhost, name, version string) string

GenerateIdentifierForAPI generates an identifier unique to the API

func GenerateIdentifierForAPIWithUUID

func GenerateIdentifierForAPIWithUUID(vhost, uuid string) string

GenerateIdentifierForAPIWithUUID generates an identifier unique to the API

func GenerateIdentifierForAPIWithoutVhost

func GenerateIdentifierForAPIWithoutVhost(name, version string) string

GenerateIdentifierForAPIWithoutVhost generates an identifier unique to the API name and version

func GetAllEnvironments

func GetAllEnvironments(apiUUID, vhost string, newEnvironments []string) []string

GetAllEnvironments returns all the environments merging new environments with already deployed environments of the given vhost of the API

func GetApplicationKeyMappingReference

func GetApplicationKeyMappingReference(keyMapping *types.ApplicationKeyMapping) string

GetApplicationKeyMappingReference returns unique reference for each key Mapping event. It is the combination of consumerKey:keyManager

func GetDeployedEnvironments

func GetDeployedEnvironments(apiUUID string) []string

GetDeployedEnvironments returns all the environments the API with `apiUUID` is deployed to

func GetEnforcerAPICache

func GetEnforcerAPICache() wso2_cache.SnapshotCache

GetEnforcerAPICache returns xds server cache.

func GetEnforcerApplicationCache

func GetEnforcerApplicationCache() wso2_cache.SnapshotCache

GetEnforcerApplicationCache returns xds server cache.

func GetEnforcerApplicationKeyMappingCache

func GetEnforcerApplicationKeyMappingCache() wso2_cache.SnapshotCache

GetEnforcerApplicationKeyMappingCache returns xds server cache.

func GetEnforcerApplicationPolicyCache

func GetEnforcerApplicationPolicyCache() wso2_cache.SnapshotCache

GetEnforcerApplicationPolicyCache returns xds server cache.

func GetEnforcerCache

func GetEnforcerCache() wso2_cache.SnapshotCache

GetEnforcerCache returns xds server cache.

func GetEnforcerKeyManagerCache

func GetEnforcerKeyManagerCache() wso2_cache.SnapshotCache

GetEnforcerKeyManagerCache returns xds server cache.

func GetEnforcerRevokedTokenCache

func GetEnforcerRevokedTokenCache() wso2_cache.SnapshotCache

GetEnforcerRevokedTokenCache return token cache

func GetEnforcerSubscriptionCache

func GetEnforcerSubscriptionCache() wso2_cache.SnapshotCache

GetEnforcerSubscriptionCache returns xds server cache.

func GetEnforcerSubscriptionPolicyCache

func GetEnforcerSubscriptionPolicyCache() wso2_cache.SnapshotCache

GetEnforcerSubscriptionPolicyCache returns xds server cache.

func GetEnforcerThrottleDataCache

func GetEnforcerThrottleDataCache() wso2_cache.SnapshotCache

GetEnforcerThrottleDataCache return throttle data cache

func GetLastSuccessState

func GetLastSuccessState(label string) (*EnforcerAPIState, *RouterResourceState)

GetLastSuccessState returns the successful enforcer state and router state which belongs to the provided label

func GetRequestEventChannel

func GetRequestEventChannel() chan RequestEvent

GetRequestEventChannel returns the state change channel. RequestEventChannel should be a singleton object

func GetVhostOfAPI

func GetVhostOfAPI(apiUUID, environment string) (vhost string, exists bool)

GetVhostOfAPI returns the vhost of API deployed in the given gateway environment

func GetXdsCache

func GetXdsCache() envoy_cachev3.SnapshotCache

GetXdsCache returns xds server cache.

func IsAPIExist

func IsAPIExist(vhost, uuid, apiName, apiVersion, organizationID string) (exists bool)

IsAPIExist returns whether a given API exists

func ListApis

func ListApis(apiType string, organizationID string, limit *int64) *apiModel.APIMeta

ListApis returns a list of objects that holds info about each API

func MarshalAPIForLifeCycleChangeEventAndReturnList

func MarshalAPIForLifeCycleChangeEventAndReturnList(apiUUID, status, gatewayLabel string) *subscription.APIList

MarshalAPIForLifeCycleChangeEventAndReturnList updates the internal map's API instances lifecycle state only if stored API Instance's or input status event is a blocked event. If no change is applied, it would return nil. Hence the XDS cache should not be updated.

func MarshalAPIMetataAndReturnList

func MarshalAPIMetataAndReturnList(apiList *types.APIList, initialAPIUUIDListMap map[string]int, gatewayLabel string) *subscription.APIList

MarshalAPIMetataAndReturnList updates the internal APIListMap and returns the XDS compatible APIList. apiList is the internal APIList object (For single API, this would contain a List with just one API) initialAPIUUIDListMap is assigned during startup when global adapter is associated. This would be empty otherwise. gatewayLabel is the environment.

func MarshalApplicationEventAndReturnList

func MarshalApplicationEventAndReturnList(application *types.Application,
	eventType EventType) *subscription.ApplicationList

MarshalApplicationEventAndReturnList handles the Application Event corresponding to the event received from message broker. And then it returns the ApplicationList.

func MarshalApplicationKeyMappingEventAndReturnList

func MarshalApplicationKeyMappingEventAndReturnList(keyMapping *types.ApplicationKeyMapping,
	eventType EventType) *subscription.ApplicationKeyMappingList

MarshalApplicationKeyMappingEventAndReturnList handles the Application Key Mapping Event corresponding to the event received from message broker. And then it returns the ApplicationKeyMappingList.

func MarshalApplicationPolicyEventAndReturnList

func MarshalApplicationPolicyEventAndReturnList(policy *types.ApplicationPolicy, eventType EventType) *subscription.ApplicationPolicyList

MarshalApplicationPolicyEventAndReturnList handles the Application Policy Event corresponding to the event received from message broker. And then it returns the ApplicationPolicyList.

func MarshalConfig

func MarshalConfig(config *config.Config) *enforcer.Config

MarshalConfig will marshal a Config struct - read from the config toml - to enfocer's CDS resource representation.

func MarshalKeyManager

func MarshalKeyManager(keyManager *types.KeyManager) *keymgt.KeyManagerConfig

MarshalKeyManager converts the data into KeyManager proto type

func MarshalMultipleApplicationKeyMappings

func MarshalMultipleApplicationKeyMappings(keymappingList *types.ApplicationKeyMappingList) *subscription.ApplicationKeyMappingList

MarshalMultipleApplicationKeyMappings is used to update the application key mappings during the startup where multiple key mappings are pulled at once. And then it returns the ApplicationKeyMappingList.

func MarshalMultipleApplicationPolicies

func MarshalMultipleApplicationPolicies(policies *types.ApplicationPolicyList) *subscription.ApplicationPolicyList

MarshalMultipleApplicationPolicies is used to update the applicationPolicies during the startup where multiple application policies are pulled at once. And then it returns the ApplicationPolicyList.

func MarshalMultipleApplications

func MarshalMultipleApplications(appList *types.ApplicationList) *subscription.ApplicationList

MarshalMultipleApplications is used to update the applicationList during the startup where multiple applications are pulled at once. And then it returns the ApplicationList.

func MarshalMultipleSubscriptionPolicies

func MarshalMultipleSubscriptionPolicies(policies *types.SubscriptionPolicyList) *subscription.SubscriptionPolicyList

MarshalMultipleSubscriptionPolicies is used to update the subscriptionPolicies during the startup where multiple subscription policies are pulled at once. And then it returns the SubscriptionPolicyList.

func MarshalMultipleSubscriptions

func MarshalMultipleSubscriptions(subscriptionsList *types.SubscriptionList) *subscription.SubscriptionList

MarshalMultipleSubscriptions is used to update the subscriptions during the startup where multiple subscriptions are pulled at once. And then it returns the SubscriptionList.

func MarshalSubscriptionEventAndReturnList

func MarshalSubscriptionEventAndReturnList(sub *types.Subscription, eventType EventType) *subscription.SubscriptionList

MarshalSubscriptionEventAndReturnList handles the Subscription Event corresponding to the event received from message broker. And then it returns the SubscriptionList.

func MarshalSubscriptionPolicyEventAndReturnList

func MarshalSubscriptionPolicyEventAndReturnList(policy *types.SubscriptionPolicy, eventType EventType) *subscription.SubscriptionPolicyList

MarshalSubscriptionPolicyEventAndReturnList handles the Subscription Policy Event corresponding to the event received from message broker. And then it returns the subscriptionPolicyList.

func SetSuccessState

func SetSuccessState(label string, enforerSuccessState EnforcerAPIState, routerSuccessState RouterResourceState)

SetSuccessState set the last successful state of enforcer and router

func UpdateAPI

func UpdateAPI(vHost string, apiProject model.ProjectAPI, environments []string) (*notifier.DeployedAPIRevision, error)

UpdateAPI updates the Xds Cache when OpenAPI Json content is provided

func UpdateEnforcerAPIList

func UpdateEnforcerAPIList(label string, apis *subscription.APIList)

UpdateEnforcerAPIList sets new update to the enforcer's Apis

func UpdateEnforcerApis

func UpdateEnforcerApis(label string, apis []types.Resource, version string)

UpdateEnforcerApis Sets new update to the enforcer's Apis

func UpdateEnforcerApplicationKeyMappings

func UpdateEnforcerApplicationKeyMappings(applicationKeyMappings *subscription.ApplicationKeyMappingList)

UpdateEnforcerApplicationKeyMappings sets new update to the enforcer's Application Key Mappings

func UpdateEnforcerApplicationPolicies

func UpdateEnforcerApplicationPolicies(applicationPolicies *subscription.ApplicationPolicyList)

UpdateEnforcerApplicationPolicies sets new update to the enforcer's Application Policies

func UpdateEnforcerApplications

func UpdateEnforcerApplications(applications *subscription.ApplicationList)

UpdateEnforcerApplications sets new update to the enforcer's Applications

func UpdateEnforcerConfig

func UpdateEnforcerConfig(configFile *config.Config)

UpdateEnforcerConfig Sets new update to the enforcer's configuration

func UpdateEnforcerKeyManagers

func UpdateEnforcerKeyManagers(keyManagerConfigList []types.Resource)

UpdateEnforcerKeyManagers Sets new update to the enforcer's configuration

func UpdateEnforcerRevokedTokens

func UpdateEnforcerRevokedTokens(revokedTokens []types.Resource)

UpdateEnforcerRevokedTokens method update the revoked tokens in the enforcer

func UpdateEnforcerSubscriptionPolicies

func UpdateEnforcerSubscriptionPolicies(subscriptionPolicies *subscription.SubscriptionPolicyList)

UpdateEnforcerSubscriptionPolicies sets new update to the enforcer's Subscription Policies

func UpdateEnforcerSubscriptions

func UpdateEnforcerSubscriptions(subscriptions *subscription.SubscriptionList)

UpdateEnforcerSubscriptions sets new update to the enforcer's Subscriptions

func UpdateEnforcerThrottleData

func UpdateEnforcerThrottleData(throttleData *throttle.ThrottleData)

UpdateEnforcerThrottleData update the key template and blocking conditions data in the enforcer

func UpdateXdsCacheWithLock

func UpdateXdsCacheWithLock(label string, endpoints []types.Resource, clusters []types.Resource, routes []types.Resource,
	listeners []types.Resource) bool

UpdateXdsCacheWithLock uses mutex and lock to avoid different go routines updating XDS at the same time

Types

type EnforcerAPIState

type EnforcerAPIState struct {
	Apis                     map[string]oasModel.MgwSwagger
	OpenAPIEnforcerApisMap   map[string]types.Resource
	APIUUIDToGatewayToVhosts map[string]map[string]string
	APIToVhostsMap           map[string]map[string]struct{}
	Version                  string
}

EnforcerAPIState Stores the last success state of the enforcer apis

type EventType

type EventType int

EventType is a enum to distinguish Create, Update and Delete Events

const (
	// CreateEvent : enum
	CreateEvent EventType = iota
	// UpdateEvent : enum
	UpdateEvent
	// DeleteEvent : enum
	DeleteEvent
)

type IDHash

type IDHash struct{}

IDHash uses ID field as the node hash.

func (IDHash) ID

func (IDHash) ID(node *corev3.Node) string

ID uses the node ID field

type RequestEvent

type RequestEvent struct {
	IsError bool
	Version string
	Node    string
}

RequestEvent is the event that is published by the xds callback (onStreamRequest)

func NewRequestEvent

func NewRequestEvent() RequestEvent

NewRequestEvent create new change event

type RouterResourceState

type RouterResourceState struct {
	APIRoutesMap           map[string][]*routev3.Route     // Envoy Routes map
	APIClustersMap         map[string][]*clusterv3.Cluster // Envoy Clusters map
	APIEndpointsMap        map[string][]*corev3.Address
	EnvoyListenerConfigMap map[string][]*listenerv3.Listener // Listener Configuration map
	EnvoyRouteConfigMap    map[string]*routev3.RouteConfiguration
	Version                string
}

RouterResourceState Stores the last successful state of the router resources

Directories

Path Synopsis
Package common includes the common functions shared between enforcer and router callbacks.
Package common includes the common functions shared between enforcer and router callbacks.

Jump to

Keyboard shortcuts

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