Implementation:Risingwavelabs Risingwave SourceTypeE
Metadata
| Property | Value |
|---|---|
| File | java/connector-node/connector-api/src/main/java/com/risingwave/connector/api/source/SourceTypeE.java
|
| Language | Java |
| Module | connector-api |
| Package | com.risingwave.connector.api.source
|
| Type | Enum |
| Lines | 45 |
Overview
SourceTypeE is a Java enum that provides a type-safe representation of supported CDC source database types in the RisingWave connector framework. It maps protobuf ConnectorServiceProto.SourceType values to corresponding Java enum constants, with an INVALID fallback for unrecognized source types.
The enum is used throughout the connector framework for type dispatch, determining which CDC engine, source handler, or configuration to use for a given source database.
Code Reference
Source Location
java/connector-node/connector-api/src/main/java/com/risingwave/connector/api/source/SourceTypeE.java
Signature
public enum SourceTypeE {
MYSQL,
POSTGRES,
CITUS,
MONGODB,
SQL_SERVER,
INVALID;
public static SourceTypeE valueOf(ConnectorServiceProto.SourceType type)
}
Imports
import com.risingwave.proto.ConnectorServiceProto;
I/O Contract
Enum Constants
| Constant | Description |
|---|---|
MYSQL |
MySQL CDC source |
POSTGRES |
PostgreSQL CDC source |
CITUS |
Citus (distributed PostgreSQL) CDC source |
MONGODB |
MongoDB CDC source |
SQL_SERVER |
Microsoft SQL Server CDC source |
INVALID |
Fallback for unrecognized or unsupported source types |
valueOf (static factory)
| Parameter | Type | Description |
|---|---|---|
type |
ConnectorServiceProto.SourceType |
The protobuf source type value to convert |
| Direction | Type | Description |
|---|---|---|
| Output | SourceTypeE |
The corresponding Java enum constant, or INVALID if the protobuf type is not recognized
|
Note: This static method shadows the default Enum.valueOf(String) method with a different parameter type. The protobuf-to-enum mapping uses a switch statement with a default case that returns INVALID.
Usage Examples
// Convert from protobuf SourceType to Java enum
ConnectorServiceProto.SourceType protoType = request.getSourceType();
SourceTypeE sourceType = SourceTypeE.valueOf(protoType);
// Use in type dispatch for creating the appropriate CDC engine
switch (sourceType) {
case MYSQL:
return createMySqlEngine(config);
case POSTGRES:
return createPostgresEngine(config);
case MONGODB:
return createMongoDbEngine(config);
case SQL_SERVER:
return createSqlServerEngine(config);
case CITUS:
return createCitusEngine(config);
case INVALID:
default:
throw new UnsupportedOperationException("Unsupported source type: " + protoType);
}
Related Pages
- CdcEngine Interface - The engine interface created based on the source type
- CdcEngineRunner Interface - Runner that manages CDC engines of different source types
- SourceHandler Interface - Source handler implementations selected by source type
- CDC Database Configuration - Configuration for different CDC source database types