ConnectorContext Class
ConnectorContext
Section titled “ConnectorContext”The ConnectorContext class is a part of the org.sunbird.obsrv.connector.model package. It encapsulates the context information for a connector instance, including its configuration, state, and statistics. This class is essential for managing the lifecycle and execution of connector instances within the Obsrv platform.
Class Definition
Section titled “Class Definition”package org.sunbird.obsrv.connector.model
import com.fasterxml.jackson.annotation.{JsonIgnore, JsonProperty}import org.sunbird.obsrv.job.model.Models.ErrorData
object Models {
case class ConnectorContext( @JsonProperty("connector_id") connectorId: String, @JsonProperty("dataset_id") datasetId: String, @JsonProperty("connector_instance_id") connectorInstanceId: String, @JsonProperty("connector_type") connectorType: String, @JsonIgnore entryTopic: String, @JsonIgnore state: ConnectorState, @JsonIgnore stats: ConnectorStats )}Fields
Section titled “Fields”connectorId: String
Section titled “connectorId: String”- Description: The unique identifier for the connector.
- Annotations:
@JsonProperty("connector_id")
datasetId: String
Section titled “datasetId: String”- Description: The unique identifier for the dataset associated with the connector.
- Annotations:
@JsonProperty("dataset_id")
connectorInstanceId: String
Section titled “connectorInstanceId: String”- Description: The unique identifier for the specific instance of the connector.
- Annotations:
@JsonProperty("connector_instance_id")
connectorType: String
Section titled “connectorType: String”- Description: The type of the connector (e.g., source, sink).
- Annotations:
@JsonProperty("connector_type")
entryTopic: String
Section titled “entryTopic: String”- Description: The entry topic for the connector. This field is ignored during JSON serialization.
- Annotations:
@JsonIgnore
- Description: The state of the connector instance, encapsulated in a ConnectorState object. This field is ignored during JSON serialization.
- Annotations:
@JsonIgnore
- Description: The statistics of the connector instance, encapsulated in a ConnectorStats object. This field is ignored during JSON serialization.
- Annotations:
@JsonIgnore
The ConnectorContext class is used to manage and track the state and statistics of a connector instance. It provides a structured way to access and manipulate the context information required for the execution of connectors.
Example
Section titled “Example”import org.sunbird.obsrv.connector.model.Models.ConnectorContextimport org.sunbird.obsrv.connector.model.{ConnectorState, ConnectorStats}import org.sunbird.obsrv.job.util.PostgresConnectionConfig
implicit val postgresConfig: PostgresConnectionConfig = // initialize config
val state = new ConnectorState("connectorInstanceId", None)val stats = new ConnectorStats("connectorInstanceId", None)
val context = ConnectorContext( connectorId = "connectorId", datasetId = "datasetId", connectorInstanceId = "connectorInstanceId", connectorType = "source", entryTopic = "entryTopic", state = state, stats = stats)
// Accessing context fieldsprintln(context.connectorId)println(context.datasetId)