Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Comments

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

Open
4cteru wants to merge 11 commits intomixigroup:tiepadrinofrom
4cteru:add_sequencer_redis
Open

[WIP] redisによるsequencerを追加#5
4cteru wants to merge 11 commits intomixigroup:tiepadrinofrom
4cteru:add_sequencer_redis

Conversation

@4cteru
Copy link

@4cteru 4cteru commented Nov 9, 2017

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

修正点/特記事項

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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants