Azure has quit [Read error: Connection reset by peer]
Azure has joined #ruby
<AndreYuhai>
I think I should rephrase my question as, I've got a class which authenticates from a website. If I use sidekiq then it will have to authenticate again and again since it creates a new instance with perform_async, but I want to re-use the already authenticated class. Basically I want a few threads to have this class initiated and authenticated and re-use it. How could I do that?
<AndreYuhai>
Maybe include Celluloid in my class and then create a pool?
<havenwood>
AndreYuhai: If you want async I/O, use Async. If you want concurrent processing, use multiple processes, or Ractors.
<havenwood>
AndreYuhai: Playing speed chess so I'll read in a sec. :)
coniptor has quit [Ping timeout: 246 seconds]
<havenwood>
AndreYuhai: That sounds like a connection pool.
<AndreYuhai>
I want concurrency so that things can get faster otherwise it will take too long to finish with only one instance.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
coniptor has quit [Ping timeout: 256 seconds]
ansimita has joined #ruby
baojg has joined #ruby
coniptor has joined #ruby
baojg has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 265 seconds]
baojg has joined #ruby
jenrzzz has joined #ruby
xco has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
xco has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jl4 has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
coniptor has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
nofxx_ has joined #ruby
nofxx__ has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
coniptor has joined #ruby
venmx has joined #ruby
jenrzzz has joined #ruby
venmx has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
MuffinPimp_ has joined #ruby
MuffinPimp has quit [Ping timeout: 256 seconds]
tomaw has quit [Quit: Quitting]
tomaw has joined #ruby
MuffinPimp_ is now known as MuffinPimp
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_whitelogger has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
Caerus has quit [Ping timeout: 256 seconds]
Caerus has joined #ruby
jenrzzz has joined #ruby
Guest47007 has joined #ruby
Guest47007 has quit [Quit: Konversation terminated!]
jenrzzz has quit [Ping timeout: 256 seconds]
baojg has quit [Remote host closed the connection]
so1e[m] has quit [Quit: Idle for 30+ days]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
akem has quit [Remote host closed the connection]
venmx has joined #ruby
coniptor has quit [Ping timeout: 256 seconds]
venmx has quit [Ping timeout: 264 seconds]
kentnl has quit [Remote host closed the connection]
kent\n has joined #ruby
akem has joined #ruby
coniptor has joined #ruby
kent\n has quit [Ping timeout: 264 seconds]
kentnl has joined #ruby
mozzarella has quit [Read error: Connection reset by peer]
kentnl is now known as kent\n
Technodrome has joined #ruby
jenrzzz has joined #ruby
cd has quit [Quit: cd]
maryo has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
viporli has joined #ruby
akem has quit [Ping timeout: 246 seconds]
akem has joined #ruby
viporli has quit [Ping timeout: 256 seconds]
maryo has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
mozzarella has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
dhanesh has joined #ruby
dhanesh has quit [Quit: Leaving]
coniptor has quit [Ping timeout: 265 seconds]
jinie_ has joined #ruby
jenrzzz has joined #ruby
jinie has quit [Ping timeout: 264 seconds]
jinie has joined #ruby
jinie_ has quit [Ping timeout: 240 seconds]
coniptor has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
DTZUZU has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
meinside has quit [Quit: Connection closed for inactivity]
jenrzzz has quit [Ping timeout: 256 seconds]
venmx has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
venmx has quit [Ping timeout: 240 seconds]
brunosaboia_ has joined #ruby
xf3rno has joined #ruby
chouhoulis has joined #ruby
coniptor has quit [Ping timeout: 256 seconds]
ansimita has left #ruby [#ruby]
chouhoulis has quit [Ping timeout: 260 seconds]
coniptor has joined #ruby
m27frogy has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
coniptor has quit [Ping timeout: 256 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
cuerbot has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
coniptor has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chouhoulis has joined #ruby
brunosaboia_ has quit [Quit: Leaving]
Rudd0 has quit [Ping timeout: 246 seconds]
hassox_ has joined #ruby
akem has quit [Remote host closed the connection]
venmx has joined #ruby
hassox has quit [Ping timeout: 260 seconds]
venmx has quit [Ping timeout: 246 seconds]
Azure|dc has quit [Read error: Connection reset by peer]
Azure has joined #ruby
venmx has joined #ruby
Axy has joined #ruby
Axy has quit [Read error: Connection reset by peer]
Axy has joined #ruby
Mia has quit [Ping timeout: 246 seconds]
venmx has quit [Ping timeout: 246 seconds]
Mia has joined #ruby
Mia has joined #ruby
akem has joined #ruby
Axy has quit [Ping timeout: 256 seconds]
Axy has joined #ruby
Axy has joined #ruby
Mia has quit [Ping timeout: 256 seconds]
AndreYuhai has joined #ruby
mic_e_ has joined #ruby
<AndreYuhai>
Hey there, how can I change the name for a has_and_belongs_to_many relationship? I need to pass the class name as a symbol but can I not use some other symbol which is shorter?
<AndreYuhai>
What I want to achieve is : has_and_belongs_to_many :actual_long_class_name -> has_and_belongs_to_many :short_name
<AndreYuhai>
maybe an alias?
<AndreYuhai>
Oh alias is for methods
jenrzzz has joined #ruby
coniptor has quit [Ping timeout: 240 seconds]
<AndreYuhai>
Oh got it! ":class_name". Read the docs ¯\_(ツ)_/¯
jenrzzz has quit [Ping timeout: 256 seconds]
coniptor has joined #ruby
Axy has quit [Read error: Connection reset by peer]
Axy has joined #ruby
Axy has joined #ruby
coniptor has quit [Ping timeout: 265 seconds]
Technodrome has joined #ruby
zapata has quit [Quit: WeeChat 3.0]
coniptor has joined #ruby
xf3rno has quit [Quit: WeeChat 2.8]
venmx has joined #ruby
venmx has quit [Ping timeout: 246 seconds]
lucasb has joined #ruby
goepsilongo has joined #ruby
_merlim_ has joined #ruby
<_merlim_>
how is that I do get the same result from this ruby snipet: signature = HMAC::SHA256.hexdigest(secret, message).upcase with the command line openssl tool ?
alexherbo2 has joined #ruby
jl4 has quit [Ping timeout: 246 seconds]
Fire-Dragon-DoL has quit [Ping timeout: 260 seconds]
coniptor has quit [Ping timeout: 265 seconds]
hiroaki has joined #ruby
Fire-Dragon-DoL has joined #ruby
Andre has joined #ruby
Andre is now known as Guest95998
coniptor has joined #ruby
AndreYuhai has quit [Ping timeout: 256 seconds]
coniptor has quit [Ping timeout: 265 seconds]
lightstalker has quit [Read error: Connection reset by peer]
lightstalker has joined #ruby
coniptor has joined #ruby
roshanavand has joined #ruby
_merlim_ has quit [Quit: Connection closed]
jenrzzz has joined #ruby
Mia has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
roshanavand1 has joined #ruby
alexherbo23 has joined #ruby
Rudd0 has joined #ruby
_merlim_ has joined #ruby
m27frogy has quit [Ping timeout: 256 seconds]
Caerus has quit [Ping timeout: 256 seconds]
endorama has quit [Ping timeout: 256 seconds]
m27frogy has joined #ruby
roshanavand has quit [Read error: Connection reset by peer]
roshanavand1 is now known as roshanavand
Caerus has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
Axy has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
_merlim_ has quit [Client Quit]
jenrzzz has joined #ruby
endorama has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
coniptor has quit [Ping timeout: 264 seconds]
coniptor has joined #ruby
xf3rno has joined #ruby
jenrzzz has joined #ruby
venmx has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
venmx has quit [Ping timeout: 240 seconds]
ChmEarl has joined #ruby
CommunistWolf is now known as CapitalistWolf
CapitalistWolf is now known as CommunistWolf
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
cd has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
GodFather has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
coniptor has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 256 seconds]
coniptor has joined #ruby
goepsilongo has quit [Read error: Connection reset by peer]
neonloop has quit [Read error: Connection reset by peer]
MzrE has joined #ruby
neonloop has joined #ruby
yokel has quit [Ping timeout: 240 seconds]
yokel has joined #ruby
jenrzzz has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 246 seconds]
Iarfen has joined #ruby
jl4 has joined #ruby
MzrE has quit [Quit: Leaving]
howdoi has quit [Quit: Connection closed for inactivity]
Technodrome has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
venmx has joined #ruby
prestorium has joined #ruby
venmx has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 246 seconds]
orbyt_ has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
coniptor has quit [Ping timeout: 256 seconds]
Guest95998 has quit [Quit: Leaving]
AndreYuhai has joined #ruby
_merlim_ has joined #ruby
<AndreYuhai>
Hey there, is there any method in ActiveRecord that returns the existing record when trying to save a duplicate one?
coniptor has joined #ruby
<AndreYuhai>
find_or_create_by
gdonald has quit [Ping timeout: 240 seconds]
work_ has joined #ruby
gdonald has joined #ruby
jenrzzz has joined #ruby
_merlim_ has quit [Quit: Connection closed]
jl4 has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
DTZUZU has joined #ruby
jenrzzz has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akem has quit [Remote host closed the connection]
akem has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
Technodrome has joined #ruby
nertzy has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
thunderbirdtr has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
ur5us_ has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
<ule>
Yep, that works
<ule>
AndreYuhai: keep in mind that in concurrent systems, that call is not atomic
<ule>
Another alternative for this is running a raw query that updates if it fails to create based on unique constraign
<ule>
ON DUPLICATE KEY... UPDATE...
<ule>
That goes a but out ActiveRecord though, it couples even more your Rails and your Database.. if you decide to move to a different database one day, this might be something you're gotta be careful so it doesn't break
<ule>
AndreYuhai: also, for Rails specific, there is a dedicated channel: #RubyOnRails
<AndreYuhai>
oh I am not really using rails but just using activerecord for the db
<AndreYuhai>
by the way
<ule>
interesting..
<ule>
Why not?
<AndreYuhai>
ule, Because I am not doing web development. I just need the DB part. :D
<AndreYuhai>
What could be the side effect of that method not being atomic?
<AndreYuhai>
find_or_create_by
<AndreYuhai>
oh now I get it
<AndreYuhai>
if two threads are trying find or create by
<AndreYuhai>
for the same record
<ule>
Well, if you have two requests at the same time, one will think the entry doesn't exist and the another one will think it exists.. then one of those will crash
<ule>
something along those lines..
akem has quit [Remote host closed the connection]
akem has joined #ruby
<ule>
Yeah, if you're using ActiveRecord you can try running a .lock or wrap that into a transaction block which would make things atomic at database level
<ule>
but if you're system is not that concurrent, then wherever
<ule>
In Rails 6 there is another method .upsert which I believe it is atomic
FastJack has quit [Ping timeout: 272 seconds]
<ule>
AndreYuhai: maybe you have the .upsert() available to you as well depending on which version of ActiveRecord you're using it
FastJack has joined #ruby
<AndreYuhai>
I am using activerecord 6.1.0 so I think I have it
<AndreYuhai>
So if I've got a transaction then are all the other threads that want to operate on the same class waiting for that transaction to be complete?
<ule>
AndreYuhai: yeah, that should do the trick
<ule>
Actually I don't know
venmx has joined #ruby
<ule>
I believe transaction would just rollback the entire set of queries inside that block if one of those fails
<ule>
To lock the entry you'd need a .lock I believe
hassox_ has quit [Ping timeout: 272 seconds]
<AndreYuhai>
Alright, thank you so much for the help ule ! I think I need to read the docs about transaction and check that upsert() method as well. Then I can ask my questions here again.
coniptor has joined #ruby
<ule>
good luck, cheers
venmx has quit [Ping timeout: 264 seconds]
prestorium has joined #ruby
jenrzzz has joined #ruby
ur5us_ has quit [Ping timeout: 264 seconds]
ur5us_ has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
Fire-Dragon-DoL has quit [Quit: Quit]
prestorium has quit [Remote host closed the connection]
prestorium has joined #ruby
Fire-Dragon-DoL has joined #ruby
prestorium has quit [Quit: prestorium]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
s3nd1v0g1us has joined #ruby
jenrzzz has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
prestorium has joined #ruby
Knight2000 has joined #ruby
Knight2000 has quit [Client Quit]
jenrzzz has quit [Ping timeout: 260 seconds]
venmx has joined #ruby
prestorium has quit [Quit: prestorium]
jenrzzz has joined #ruby
work_ has quit [Quit: Connection closed for inactivity]
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
coniptor has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 246 seconds]
Rounin has quit [Ping timeout: 246 seconds]
roshanavand1 has joined #ruby
coniptor has joined #ruby
roshanavand has quit [Ping timeout: 246 seconds]
roshanavand1 is now known as roshanavand
bambanx has joined #ruby
howdoi has joined #ruby
jenrzzz has joined #ruby
alexherbo26 has joined #ruby
alexherbo2 has quit [Read error: Connection reset by peer]