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
package job_scheduler | |
import ( | |
"context" | |
"database/sql/driver" | |
"encoding/json" | |
"fmt" | |
"log" | |
"time" |
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
Engines::Core::Rpc::Client.new( | |
service: ::Rpc::Services::LiveCommunications::Messages | |
).get_message( | |
::Rpc::Backend::GetMessageRequest.new( | |
message_id: "21ef149a-09ac-11ed-861d-0242ac120002" | |
) | |
) |
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
syntax = "proto3"; | |
package rpc.my_package; | |
service MyService { | |
rpc GetSomething(GetSomethingRequest) returns (GetSomethingResponse) {} | |
} |
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
# concurrent migration strategy | |
# when migrating through this script | |
# you can launch it on multiple processes | |
# and they will deal with the concurrency by | |
# themselves without interrupting or crashing | |
class MigrateConcurrently | |
class Error < StandardError; end | |
DELAY_BETWEEN_CYCLES_IN_SECONDS = 3 | |
MAX_CYCLES = 100 |
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
class MigrateConcurrently | |
class Error < StandardError; end | |
... | |
def raise_if_max_cycles_reached | |
... | |
raise Error, ... | |
end | |
end |
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
class MigrateConcurrently | |
DELAY_BETWEEN_CYCLES_IN_SECONDS = 3 | |
MAX_CYCLES = 100 | |
def initialize; end | |
def perform | |
Logger.info( | |
... | |
delay_between_cycles_in_seconds: DELAY_BETWEEN_CYCLES_IN_SECONDS, |
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
# concurrent migration strategy | |
# when migrating through this script | |
# you can launch it on multiple processes | |
# and they will deal with the concurrency by | |
# themselves without interrupting or crashing | |
class MigrateConcurrently | |
... | |
end |
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
class MigrateConcurrently | |
... | |
def perform | |
... | |
Logger.info( | |
... | |
cycle: cycles.current, | |
max_cycles: cycles.max, | |
) |
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
class Cycles | |
attr_reader :current, :max | |
def initialize(current: 1, max: 1) | |
@current = current | |
@max = max | |
end | |
def next | |
@current += 1 |
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
class MigrateConcurrently | |
def initialize; end | |
def perform | |
# migration taken directly | |
# from ActiveRecord | |
ActiveRecord::Base.connection.migration_context.migrate | |
rescue ActiveRecord::ConcurrentMigrationError | |
# we log the details of the migrations | |
# through our logger |
NewerOlder