-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Service API to be used directly by the handlers (#11587)
- Loading branch information
1 parent
64fb7fe
commit 5e8570b
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
7 changes: 6 additions & 1 deletion
7
airbyte-data/src/main/kotlin/io/airbyte/data/services/ConnectionTimelineEventService.kt
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package io.airbyte.data.services | ||
|
||
import io.airbyte.data.repositories.entities.ConnectionTimelineEvent | ||
import io.airbyte.data.services.shared.ConnectionEvent | ||
import java.util.UUID | ||
|
||
interface ConnectionTimelineEventService { | ||
fun writeEvent(event: ConnectionTimelineEvent): ConnectionTimelineEvent | ||
fun writeEvent( | ||
connectionId: UUID, | ||
event: ConnectionEvent, | ||
): ConnectionTimelineEvent | ||
} |
15 changes: 14 additions & 1 deletion
15
...src/main/kotlin/io/airbyte/data/services/impls/data/ConnectionTimelineEventServiceImpl.kt
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 |
---|---|---|
@@ -1,13 +1,26 @@ | ||
package io.airbyte.data.services.impls.data | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import io.airbyte.data.repositories.ConnectionTimelineEventRepository | ||
import io.airbyte.data.repositories.entities.ConnectionTimelineEvent | ||
import io.airbyte.data.services.ConnectionTimelineEventService | ||
import io.airbyte.data.services.shared.ConnectionEvent | ||
import jakarta.inject.Singleton | ||
import java.util.UUID | ||
|
||
@Singleton | ||
class ConnectionTimelineEventServiceImpl(private val repository: ConnectionTimelineEventRepository) : ConnectionTimelineEventService { | ||
override fun writeEvent(event: ConnectionTimelineEvent): ConnectionTimelineEvent { | ||
override fun writeEvent( | ||
connectionId: UUID, | ||
connectionEvent: ConnectionEvent, | ||
): ConnectionTimelineEvent { | ||
val serializedEvent = MAPPER.writeValueAsString(connectionEvent) | ||
val event = | ||
ConnectionTimelineEvent(null, connectionId, connectionEvent.getUserId(), connectionEvent.getEventType().toString(), serializedEvent, null) | ||
return repository.save(event) | ||
} | ||
|
||
companion object { | ||
private val MAPPER = ObjectMapper() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
airbyte-data/src/main/kotlin/io/airbyte/data/services/shared/ConnectionEvent.kt
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,15 @@ | ||
package io.airbyte.data.services.shared | ||
|
||
import java.util.UUID | ||
|
||
interface ConnectionEvent { | ||
enum class Type { | ||
SYNC_SUCCEEDED, | ||
} | ||
|
||
fun getUserId(): UUID? { | ||
return null | ||
} | ||
|
||
fun getEventType(): Type | ||
} |
38 changes: 38 additions & 0 deletions
38
airbyte-data/src/main/kotlin/io/airbyte/data/services/shared/SyncSucceededEvent.kt
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,38 @@ | ||
package io.airbyte.data.services.shared | ||
|
||
class SyncSucceededEvent( | ||
private val jobId: Long, | ||
private val startTimeEpochSeconds: Long, | ||
private val endTimeEpochSeconds: Long, | ||
private val bytesLoaded: Long, | ||
private val recordsLoaded: Long, | ||
private val attemptsCount: Int, | ||
) : ConnectionEvent { | ||
fun startTimeEpochSeconds(): Long { | ||
return this.startTimeEpochSeconds | ||
} | ||
|
||
fun endTimeEpochSeconds(): Long { | ||
return endTimeEpochSeconds | ||
} | ||
|
||
fun getJobId(): Long { | ||
return jobId | ||
} | ||
|
||
fun getBytesLoaded(): Long { | ||
return bytesLoaded | ||
} | ||
|
||
fun getRecordsLoaded(): Long { | ||
return recordsLoaded | ||
} | ||
|
||
fun getAttemptsCount(): Int { | ||
return attemptsCount | ||
} | ||
|
||
override fun getEventType(): ConnectionEvent.Type { | ||
return ConnectionEvent.Type.SYNC_SUCCEEDED | ||
} | ||
} |