-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projection implementation for MySQL support #177
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.pekko.projection.r2dbc.internal.mysql | ||
|
||
import java.time.Clock | ||
|
||
import org.apache.pekko | ||
import pekko.actor.typed.ActorSystem | ||
import pekko.annotation.InternalApi | ||
import pekko.persistence.r2dbc.internal.R2dbcExecutor | ||
import pekko.persistence.r2dbc.internal.Sql.DialectInterpolation | ||
import pekko.projection.BySlicesSourceProvider | ||
import pekko.projection.ProjectionId | ||
import pekko.projection.r2dbc.R2dbcProjectionSettings | ||
import pekko.projection.r2dbc.internal.R2dbcOffsetStore | ||
|
||
/** | ||
* INTERNAL API | ||
*/ | ||
@InternalApi | ||
private[projection] class MySQLR2dbcOffsetStore( | ||
projectionId: ProjectionId, | ||
sourceProvider: Option[BySlicesSourceProvider], | ||
system: ActorSystem[_], | ||
settings: R2dbcProjectionSettings, | ||
r2dbcExecutor: R2dbcExecutor, | ||
clock: Clock = Clock.systemUTC()) | ||
extends R2dbcOffsetStore(projectionId, sourceProvider, system, settings, r2dbcExecutor, clock) { | ||
|
||
override lazy val timestampSql: String = "NOW(6)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a dialect method, can we abstract a class 'Dialect'? like Hibernate SQL Dialects does. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have an ADT for |
||
|
||
override val upsertOffsetSql: String = sql""" | ||
INSERT INTO $offsetTable | ||
(projection_name, projection_key, current_offset, manifest, mergeable, last_updated) | ||
VALUES (?,?,?,?,?,?) AS excluded | ||
ON DUPLICATE KEY UPDATE | ||
current_offset = excluded.current_offset, | ||
manifest = excluded.manifest, | ||
mergeable = excluded.mergeable, | ||
last_updated = excluded.last_updated""" | ||
|
||
override val updateManagementStateSql: String = sql""" | ||
INSERT INTO $managementTable | ||
(projection_name, projection_key, paused, last_updated) | ||
VALUES (?,?,?,?) AS excluded | ||
ON DUPLICATE KEY UPDATE | ||
paused = excluded.paused, | ||
last_updated = excluded.last_updated""" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are breaking backwards compatibility here, can we convert from
case class
toclass
too? Similar to howR2dbcSettings
is implemented.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course this class is different from
R2dbcSettings
in a way that users can manually construct it - it is not constructed by config only, so will have to keep the means to set/modify its attributes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjfanning Do you have a preferred solution for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the TODO on the class - so I don't mind a rewrite for 1.1.0.
It would still be nice to minimise source incompatible changes - i.e. code with against 1.0.0 would ideally still be compilable with 1.1.0.