-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ConnectivitySignalEnrichmentFacade configurable via extension me…
…chanism * Make instantiate DittoCachingSignalEnrichmentFacade explicitly instead of using the extension mechanism here. The extension is only relevant for search. * Instead of having two classes for caching and none-caching a single class handles it which can be configured Signed-off-by: Yannic Klem <yannic.klem@bosch.io>
- Loading branch information
Showing
21 changed files
with
275 additions
and
790 deletions.
There are no files selected for viewing
66 changes: 0 additions & 66 deletions
66
...e/ditto/connectivity/service/mapping/ConnectivityByRoundTripSignalEnrichmentProvider.java
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
...lipse/ditto/connectivity/service/mapping/ConnectivityCachingSignalEnrichmentProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...lipse/ditto/connectivity/service/mapping/DefaultConnectivitySignalEnrichmentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.connectivity.service.mapping; | ||
|
||
import org.eclipse.ditto.connectivity.model.ConnectionId; | ||
import org.eclipse.ditto.edge.service.dispatching.EdgeCommandForwarderActor; | ||
import org.eclipse.ditto.internal.models.signalenrichment.ByRoundTripSignalEnrichmentFacade; | ||
import org.eclipse.ditto.internal.models.signalenrichment.DefaultSignalEnrichmentProviderConfig; | ||
import org.eclipse.ditto.internal.models.signalenrichment.DittoCachingSignalEnrichmentFacade; | ||
import org.eclipse.ditto.internal.models.signalenrichment.SignalEnrichmentFacade; | ||
|
||
import com.typesafe.config.Config; | ||
|
||
import akka.actor.ActorSystem; | ||
|
||
/** | ||
* Provider for Connectivity-service of signal-enriching facades that uses an async Caffeine cache in order to load | ||
* extra data to enrich. | ||
*/ | ||
public final class DefaultConnectivitySignalEnrichmentProvider implements ConnectivitySignalEnrichmentProvider { | ||
|
||
private static final String COMMAND_FORWARDER_ACTOR_PATH = | ||
"/user/connectivityRoot/" + EdgeCommandForwarderActor.ACTOR_NAME; | ||
private static final String CACHE_DISPATCHER = "signal-enrichment-cache-dispatcher"; | ||
private final SignalEnrichmentFacade facade; | ||
|
||
/** | ||
* Instantiate this provider. Called by reflection. | ||
* | ||
* @param actorSystem The actor system for which this provider is instantiated. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public DefaultConnectivitySignalEnrichmentProvider(final ActorSystem actorSystem, final Config config) { | ||
final var commandHandler = actorSystem.actorSelection(COMMAND_FORWARDER_ACTOR_PATH); | ||
final var providerConfig = DefaultSignalEnrichmentProviderConfig.of(config); | ||
final var delegate = ByRoundTripSignalEnrichmentFacade.of(commandHandler, providerConfig.getAskTimeout()); | ||
if (providerConfig.isCachingEnabled()) { | ||
final var cacheLoaderExecutor = actorSystem.dispatchers().lookup(CACHE_DISPATCHER); | ||
facade = DittoCachingSignalEnrichmentFacade.newInstance( | ||
delegate, | ||
providerConfig.getCacheConfig(), | ||
cacheLoaderExecutor, | ||
"connectivity"); | ||
} else { | ||
facade = delegate; | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public SignalEnrichmentFacade getFacade(final ConnectionId connectionId) { | ||
return facade; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.