Skip to content
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

[WIP] redisによるsequencerを追加 #5

Open
wants to merge 11 commits into
base: tiepadrino
Choose a base branch
from

Conversation

4cteru
Copy link

@4cteru 4cteru commented Nov 9, 2017

redisを利用したsequencerを追加します

修正点/特記事項

  • redisを利用したsequencerの追加
  • シーケンス番号を保持するキーの存在チェックを行うためにlua scriptを利用
  • redis.getを利用すると文字列として返却されるので数値に変換して返却
  • 一部動作しなかったspecの修正

@@ -24,3 +24,5 @@
config.before(:each) do
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙄

@KumatomatomaKu
Copy link

良さそうに思えた!(変な空白ラインの差分以外は)

README.rdoc Outdated
seq_type: redis
connection: redis_sequencer # <-- redis sequencer name
shards:
- connection: redis_shard_1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一瞬各shard DBもredisにできるのかのように見えますね

@4cteru 4cteru changed the title redisによるsequencerを追加 [WIP] redisによるsequencerを追加 Nov 10, 2017
@seq_shard = SeqShard.new(seq)
seq = (@options[:seq] || @config[:seq])
if seq
if seq.values.size > 0 && seq.values.first["seq_type"] == "mysql"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/m4cteru/activerecord-turntable/blob/e643f3456b4c00fb55924a37ef0a11ec26e6517a/lib/active_record/turntable/sequencer.rb#L23

seq_type無指定の時はmysqlのようですので、
その場合も@seq_shardにセットする必要がありそうです。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/drecom/activerecord-turntable/pull/28/files#diff-aa73b66f1c9647a7824bb29f250b55e8R49
とかみても、
seqはそもそもconfig/turntable.ymlではhash想定?なので、
seq["seq_type"]を評価する必要ありそうです。

seq = (@options[:seq] || @config[:seq])
if seq
if seq.values.size > 0 && seq.values.first["seq_type"] == "mysql"
@seq_shard = SeqShard.new(seq.values.first)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/m4cteru/activerecord-turntable/blob/e643f3456b4c00fb55924a37ef0a11ec26e6517a/lib/active_record/turntable/shard.rb#L8

をみると、hashを期待しているようなので、
seqをわたせばよさそうです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants