/**
 * Copyright 2017 Netflix, Inc.
 *
 * Licensed 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.
 */
/**
 * 
 */
package com.netflix.conductor.core.events;

import java.util.HashMap;
import java.util.Map;

import com.netflix.conductor.core.events.queue.ObservableQueue;

/**
 * @author Viren
 * Static holders for internal event queues
 */
public class EventQueues {
	
	public enum QueueType {
		sqs, conductor
	}
	
	private static Map<QueueType, EventQueueProvider> providers = new HashMap<>();

	private EventQueues() {
		
	}

	public static void registerProvider(QueueType type, EventQueueProvider provider) {
		providers.put(type, provider);
	}
	
	public static Map<QueueType, EventQueueProvider> providers() {
		return providers;
	}
	
	public static ObservableQueue getQueue(String event) {
		String typeVal = event.substring(0, event.indexOf(':'));
		String queueURI = event.substring(event.indexOf(':') + 1);
		QueueType type = QueueType.valueOf(typeVal);
		EventQueueProvider provider = providers.get(type);
		return provider.getQueue(queueURI);
	}
}

@@ -1506,16 +1506,42 @@
 (type);%0A
+%09%09if(provider != null) %7B%0A%09
 %09%09return
@@ -1569,14 +1569,37 @@
 eueURI);
+%09%0A%09%09%7D%0A%09%09return null;%0A%09%09
 %0A%09%7D%0A%7D%0A

return null when no event provider is registered for the given event type