Skip to content

Commit

Permalink
feature: Remove "Custom Wildcard Subscription"-Logic for Specs
Browse files Browse the repository at this point in the history
Closes: #60
Signed-off-by: Andre Weber <andre.weber3@etas.com>
  • Loading branch information
wba2hi committed Dec 7, 2023
1 parent 85f9a28 commit 2632b4d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ internal class DataBrokerTransporter(
val entry = entryUpdate.entry

subscription.listeners.forEach { observer ->
observer.onPropertyChanged(vssPath, field, entry)
observer.onPropertyChanged(entry.path, field, entry)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import org.eclipse.kuksa.DataBrokerTransporter
import org.eclipse.kuksa.PropertyListener
import org.eclipse.kuksa.VssSpecificationListener
import org.eclipse.kuksa.extension.TAG
import org.eclipse.kuksa.extension.createProperties
import org.eclipse.kuksa.proto.v1.Types
import org.eclipse.kuksa.proto.v1.Types.Field
import org.eclipse.kuksa.vsscore.model.VssProperty
import org.eclipse.kuksa.vsscore.model.VssSpecification
import org.eclipse.kuksa.vsscore.model.vssProperties

/**
* Creates [Subscription]s to the DataBroker to get notified about changes on the underlying vssPaths and fields.
Expand Down Expand Up @@ -91,13 +91,13 @@ internal class DataBrokerSubscriber(private val dataBrokerTransporter: DataBroke
field: Field = Field.FIELD_VALUE,
listener: VssSpecificationListener<T>,
) {
val leafProperties = specification.createProperties(field)
val vssPaths = leafProperties.map { it.vssPath }
val vssPath = specification.vssPath

val specificationPropertyListener = SpecificationPropertyListener(specification, vssPaths, listener)
vssPaths.forEach { vssPath ->
subscribe(vssPath, field, specificationPropertyListener)
}
val leafProperties = specification.vssProperties
val childPropertiesPaths = leafProperties.map { it.vssPath }

val specificationPropertyListener = SpecificationPropertyListener(specification, childPropertiesPaths, listener)
subscribe(vssPath, field, specificationPropertyListener)
}

/**
Expand All @@ -111,13 +111,13 @@ internal class DataBrokerSubscriber(private val dataBrokerTransporter: DataBroke
field: Field = Field.FIELD_VALUE,
listener: VssSpecificationListener<T>,
) {
val leafProperties = specification.createProperties(field)
val vssPaths = leafProperties.map { it.vssPath }
val vssPath = specification.vssPath

val specificationPropertyListener = SpecificationPropertyListener(specification, vssPaths, listener)
vssPaths.forEach { vssPath ->
unsubscribe(vssPath, field, specificationPropertyListener)
}
val leafProperties = specification.vssProperties
val childPropertiesPaths = leafProperties.map { it.vssPath }

val specificationPropertyListener = SpecificationPropertyListener(specification, childPropertiesPaths, listener)
unsubscribe(vssPath, field, specificationPropertyListener)
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ internal class SpecificationPropertyListener<T : VssSpecification>(
vssPaths: Collection<String>,
private val listener: VssSpecificationListener<T>,
) : PropertyListener {
// TODO: Remove as soon as the server supports subscribing to vssPaths which are not VssProperties
// Reduces the load on the observer for big VssSpecifications. We wait for the initial update
// of all VssProperties before notifying the observer about the first batch
private val initialSubscriptionUpdates = vssPaths.associateWith { false }.toMutableMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class Subscription(

for (entryUpdate in lastSubscribeResponse.updatesList) {
val entry = entryUpdate.entry
observer.onPropertyChanged(vssPath, field, entry)
observer.onPropertyChanged(entry.path, field, entry)
}
}
},
Expand Down

0 comments on commit 2632b4d

Please sign in to comment.