func OpenInstance(nodeID string, xdsPath string, newPolicyClient func(path, nodeID string, updater PolicyUpdater) PolicyClient,
	accessLogPath string, newAccessLogger func(accessLogPath string) AccessLogger) uint64 {
	mutex.Lock()
	defer mutex.Unlock()

	// Check if have an instance with these params already
	for id, old := range instances {
		oldXdsPath := ""
		if old.policyClient != nil {
			oldXdsPath = old.policyClient.Path()
		}
		oldAccessLogPath := ""
		if old.accessLogger != nil {
			oldAccessLogPath = old.accessLogger.Path()
		}
		if (nodeID == "" || old.nodeID == nodeID) && xdsPath == oldXdsPath && accessLogPath == oldAccessLogPath {
			old.openCount++
			log.Debugf("Opened existing library instance %d, open count: %d", id, old.openCount)
			return id
		}
	}

	ins := NewInstance(nodeID, newAccessLogger(accessLogPath))
	// policy client needs the instance so we set it after instance has been created
	ins.policyClient = newPolicyClient(xdsPath, ins.nodeID, ins)

	instances[instanceId] = ins

	log.Debugf("Opened new library instance %d", instanceId)

	return instanceId
}
// OpenInstance creates a new instance or finds an existing one with equivalent parameters.
// returns the instance id.
OpenInstance creates a new instance or finds an existing one with equivalent parameters.
returns the instance id.
// OpenInstance creates a new instance or finds an existing one with equivalent parameters . // returns the instance id .
func OpenInstance(nodeID string, xdsPath string, newPolicyClient func(path, nodeID string, updater PolicyUpdater) PolicyClient,
	accessLogPath string, newAccessLogger func(accessLogPath string) AccessLogger) uint64 {
	mutex.Lock()
	defer mutex.Unlock()
	for id, old := range instances {
		oldXdsPath := ""
		if old.policyClient != nil {
			oldXdsPath = old.policyClient.Path()
		}
		oldAccessLogPath := ""
		if old.accessLogger != nil {
			oldAccessLogPath = old.accessLogger.Path()
		}
		if (nodeID == "" || old.nodeID == nodeID) && xdsPath == oldXdsPath && accessLogPath == oldAccessLogPath {
			old.openCount++
			log.Debugf("Opened existing library instance %d, open count: %d", id, old.openCount)
			return id
		}
	}
	ins := NewInstance(nodeID, newAccessLogger(accessLogPath))
	ins.policyClient = newPolicyClient(xdsPath, ins.nodeID, ins)
	instances[instanceId] = ins
	log.Debugf("Opened new library instance %d", instanceId)
	return instanceId
}
func OpenInstance ( nodeID string , xdsPath string , newPolicyClient func ( path , nodeID string , updater PolicyUpdater ) PolicyClient , accessLogPath string , newAccessLogger func ( accessLogPath string ) AccessLogger ) uint64 { mutex . Lock ( ) defer mutex . Unlock ( ) for id , old := range instances { oldXdsPath := " " if old . policyClient != nil { oldXdsPath = old . policyClient . Path ( ) } oldAccessLogPath := " " if old . accessLogger != nil { oldAccessLogPath = old . accessLogger . Path ( ) } if ( nodeID == " " || old . nodeID == nodeID ) && xdsPath == oldXdsPath && accessLogPath == oldAccessLogPath { old . openCount ++ log . Debugf ( " " , id , old . openCount ) return id } } ins := NewInstance ( nodeID , newAccessLogger ( accessLogPath ) ) ins . policyClient = newPolicyClient ( xdsPath , ins . nodeID , ins ) instances [ instanceId ] = ins log . Debugf ( " " , instanceId ) return instanceId }
OpenInstance creates a new instance or finds an existing one with equivalent parameters.
OpenInstance creates a new instance or finds an existing one with equivalent parameters .
// Check if have an instance with these params already // policy client needs the instance so we set it after instance has been created