@Override
public void addFollowerCallback(HashId id, long environmentId, ZonedDateTime expiresAt, ZonedDateTime storedUntil) {
try (PooledDb db = dbPool.db()) {
try (
PreparedStatement statement =
db.statement(
"INSERT INTO follower_callbacks (id, state, environment_id, expires_at, stored_until) VALUES (?,?,?,?,?)"
)
) {
statement.setBytes(1, id.getDigest());
statement.setInt(2, CallbackService.FollowerCallbackState.STARTED.ordinal());
statement.setLong(3, environmentId);
statement.setLong(4, StateRecord.unixTime(expiresAt));
statement.setLong(5, StateRecord.unixTime(storedUntil));
db.updateWithStatement(statement);
}
} catch (SQLException se) {
se.printStackTrace();
throw new Failure("follower callback save failed:" + se);
} catch (Exception e) {
e.printStackTrace();
}
}