logux / logux_rails Goto Github PK
View Code? Open in Web Editor NEWRails client for Logux server
Home Page: https://logux.org/
License: MIT License
Rails client for Logux server
Home Page: https://logux.org/
License: MIT License
Logux add:: {
"version": 0,
"password": "xxxx",
"commands": [
[
"action",
{
"type": "amplifr/autopilot/status",
"status": "noPostsChecked",
"projectId": 16484
},
{
"clients": [
"74205:UI40z-2U"
]
}
]
]
}
Write to Logux response: ["processed","1543917265964 74205:UI40z-2U:RJZpH8Ly 0"]
Write to Logux response: ]
I am not at all familiar with Logux so please dismiss this ticket if it does not make sense, but I saw it uses websockets, which I've read is not necessarily always reliable:
https://discuss.rubyonrails.org/t/actioncable-messaging-doesnt-recover-from-disconnect-reconnect/75074/2
https://samsaffron.com/archive/2015/12/29/websockets-caution-required
Maybe supporting MessageBus could help?
➤ b rake spec
/home/ai/.rubies/2.5.3/bin/ruby -I/home/ai/Dev/logux_rails/.bundle/gems/rspec-core-3.8.0/lib:/home/ai/Dev/logux_rails/.bundle/gems/rspec-support-3.8.0/lib /home/ai/Dev/logux_rails/.bundle/gems/rspec-core-3.8.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`
set to false is deprecated. SQLite databases have used 't' and 'f' to serialize
boolean values and must have old data converted to 1 and 0 (its native boolean
serialization) before setting this flag to true. Conversion can be accomplished
by setting up a rake task which runs
ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1)
ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0)
for all models and all boolean columns, after which the flag must be set to
true by adding the following to your application.rb file:
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
(called from <top (required)> at /home/ai/Dev/logux_rails/spec/rails_helper.rb:13)
...............................WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass)` risks false positives, since literally any other error would cause the expectation to pass, including those raised by Ruby (e.g. NoMethodError, NameError and ArgumentError), meaning the code you are intending to test may not even get reached. Instead consider using `expect { }.not_to raise_error` or `expect { }.to raise_error(DifferentSpecificErrorClass)`. This message can be suppressed by setting: `RSpec::Expectations.configuration.on_potential_false_positives = :nothing`. Called from /home/ai/Dev/logux_rails/spec/logux/model/updates_deprecator_spec.rb:18:in `block (3 levels) in <top (required)>'.
...................................
@wilddima warnings are not the Logux way :)
We used 0
version in HTTP requests. I will release Logux Server 0.3 tomorrow and will bump HTTP protocol version to 1
.
@dsalahutdinov can you update it too?
We need to use here https://github.com/logux/logux_rails/blob/master/lib/logux/model/updater.rb#L30 different logic: https://github.com/logux/core/blob/master/is-first-older.js
Do minor cleanup for test environment:
spec/dummy/bin
We need backport Logux.undo(meta, reason)
shortcut to Rails
https://github.com/logux/logux-server/blob/master/base-server.js#L650-L661
Now gem writes ['error', 'message']
. We need to write: ['error', meta.id, e.backtrace.join("\n")]
Would be nice and helpful to use
expect(response).to logux_undo(reason: 'limitExceeded')
where reason is optional argument
Hi guys, It seems I've made everything as written in your basic guide but I am getting "ActionController::RoutingError (No route matches [POST] "/")" from rails server when logux proxy server sends initial auth request.
Also is there a reason why logux_rails v2 gem doesn't support rails 6.1? (it requires rails >= 5.0, < 6.1)
Sorry in advance, I am new to ruby world.
send_back(action, meta)
method will do add an action with client_id
from current action/subscription.
Logux.add(action, { clientIds: [action.client_id], ...meta })
It will be just a syntax sugar
Current output:
How we can imporve it:
Write to logux
→ Write to Logux response
Searching action for action: #{action}, meta: #{meta}
→ Searching action for Logux action: #{action}, meta: #{meta}
Searching policy for action: #{action}, meta: #{meta}
→ Searching policy for Logux action: #{action}, meta: #{meta}
Logux add
→ Receive from Logux
Receive from Logux
Description will be soon...
Add to Action params filtering as in Rails controllers
https://weblog.rubyonrails.org/2012/3/21/strong-parameters/
I am adding prices
channel to Amplifr. Gem force me to have some code for the channel. So I created app/logux/channels/prices.rb
with:
module Channels
class Prices < Channels::Base
end
end
But gem start to write this response on subscription:
{
"version": 0,
"password": "secret",
"commands": [
[
"action",
1,
{
"nodeIds": [
"380:TMt6iOHX"
]
}
],
[
"action",
2,
{
"nodeIds": [
"380:TMt6iOHX"
]
}
]
]
}
Seems like without initial_data
, gem anyway send action
command.
ChangeLog is very important for big open source projects
Здравствуйте, Дмитрий.
Заранее извиняюсь, что пишу в github.
Я Дмитрий. 27 августа на вашу почту отправлял вакансии Ruby on Rails dev.
Хочу узнать вы готовы рассмотреть предложение о работе?
If Logux sends { type: 'logux/susbcribe', channel: 'unknown' }
, Rails will answer:
Write to Logux response: ["unknownChannel","1554484116313 380:R7BNGAP5:Pjoz3bdE 0"]
Write to Logux response: ]
But Logux wait for [["unknownChannel", …]]
, array in array.
/cc @dsalahutdinov
Generate meta.id
in Logux.add()
according JS-version https://github.com/logux/logux-core/blob/master/log.js#L171-L180
API should be:
Logux.add(action, { meta })
If user needs batch, they should use:
Logux.add_batch([[action, meta], [action, meta], …])
Maybe we should even use Logux.add(action, meta)
to be consistence with JS API.
Logux.undo()
should copy all re-send keys from origin action (channels
, etc).
Here is JS implementation: https://github.com/logux/server/blob/master/base-server.js#L676-L682
We should answer ['unknownAction', meta.id]
and ['unknownChannel', meta.id]
instead of error
Logux::Action
has few methods, which are not part of Logux core: action_name
, channel_name
, channel_id
.
Let’s remove them since we should not copy Amplifr-only methods to core system.
Хороший новости — наконец-то у нас есть спецификация протокола между бэкендом и Логаксом:
https://logux.io/protocols/backend/spec/#action
Плохие новости — протокол пришлось обновить. Один парень нашёл, что наш старый API (когда клиент выставляет кому переслать событий) провоцировал на шибки безопасности (волноваться не стоит, у нас на Амплифере всё безопасно). Теперь сервер будет решать, кому переслать новое событие.
В Logux::ActionController
надо добавить метод resend
:
def resend
{ channel: "users/#{ action.userId }" }
end
logux_rails
при получении команды action
должен сначала ответить ['resend', meta.id, { "channel": "users/1" }]
, а потом как раньше approved
и processed
.
@wilddima @dsalahutdinov could you add GitHub access for me?
If Rails app and Logux server will have different time, it could create problems
With send_to_logux
we can check what Rails sent to Logux during specs. But sent days contains some inconsistent days, for example meta.id
.
We need to add pattern matching to send_to_logux
to allow to pass something like id: kind_of(String)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.