Comments (29)
In general, I think it might make sense to add these methods in ServiceActor::Result
. BTW @afuno what's the use-case for calling public_send/object_id/instance_variables on service result?
from actor.
I'll open a PR soon if you don't mind @sunny
@afuno Are there any other problematic methods generating warnings in your codebase?
from actor.
@afuno Are there any other problematic methods generating warnings in your codebase?
At the moment I can only talk about those above.
from actor.
I am guessing that those introspection methods are called by test-tooling like RSpec to build test doubles.
We're using RSpec mocking actively but didn't encounter any warnings. But I'm pretty sure there are many gems/tools which don't paly nice with BasicObject
, for example, awesome_print
's missing Kernel#ai
breaks result introspection
from actor.
@afuno Can you share with us one example of code that triggers this warning that you find unexpected? ππ»
Unfortunately, I can't at the moment.
The problems described above have been resolved.
You can now use the newly-released v3.8.1, too.
But this does not solve the problem in total.
For now, I have fixed the 3.7
release line until better times. Unfortunately, at the moment I do not have time to understand hundreds of problems in tests.
from actor.
@sunny Thanks for adding compatibility. Apparently, release 3.9 has fixed the main problems described earlier.
However, there are still the following problems:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `title`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `nil?`
And what is most important is:
ArgumentError:
input `error` overrides `ServiceActor::Result` instance method
Which reacts to this:
input :error, type: String, allow_nil: true
from actor.
Thank you for the detailed report @andrik! Indeed the #methods
method is used by introspection tools as well. Iβve merged #159 which should fix this. Can you try again from main
, please? ππ»
from actor.
Hi @sunny
I tested and it worked.
Thank you π
from actor.
@sunny Apparently the problems that were described above have indeed been resolved. Thank you. Can you please make a release so I can finalize this in projects?
from actor.
Okay, I understood the changes. Solution:
ServiceActor::Result.new(failure: true, error: "Some error")
from actor.
This didn't actually solve the problem. There are a huge number of tests. Some of them were resolved through the example I gave above. But most tests continue to fail, for example with comments like this:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `public_send`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `public_send`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `public_send`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `public_send`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `object_id`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `object_id`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `instance_variables`
These comments are accompanied by this error:
NoMethodError:
undefined method `empty?' for nil
from actor.
In general, I think it might make sense to add these methods in
ServiceActor::Result
. BTW @afuno what's the use-case for calling public_send/object_id/instance_variables on service result?
This is a deep dependence.
from actor.
I am guessing that those introspection methods are called by test-tooling like RSpec to build test doubles.
from actor.
@afuno Could you please run your suite against #148?
from actor.
The problems described above have been resolved. But overall the problem is not solved. Next error:
NoMethodError: undefined method `expected' for an instance of RSpec::Matchers::BuiltIn::RaiseError
from actor.
Could you please show some context of the error above? π€
from actor.
Could you please show some context of the error above? π€
This problem is resolved. It was about failure?
and failure
.
from actor.
I keep receiving a huge number of notifications like this:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor.
I can't give an example of method names, but there are many of them and they are different. All of them are related to the specifics of the project.
from actor.
In general, if that's not a bug, that means that you are trying to invoke some method on ServiceActor::Result
which was not defined as output
in actor definition
from actor.
@afuno Can you share with us one example of code that triggers this warning that you find unexpected? ππ»
from actor.
The problems described above have been resolved.
You can now use the newly-released v3.8.1, too.
from actor.
FYI 3.9.0 has been released with #153, which could be related to your issues.
from actor.
Thank you for reporting this back.
-
For
#title
, the warning is here to encourage you to not call the method if the output has not been defined.For example you could make sure the result has succeeded before calling
#title
on it, or you can even check if the#title
method is defined. -
For
#nil?
Iβll add this to the default methods on results ππ» -
For naming an input
:error
Iβll make sure we can allow this ππ»
from actor.
@afuno Iβve fixed both :errors
and #nil?
issue. Can you try using the main
branch and see if the only issue left on your code base are the warnings on title
? ππ»
gem "service_actor", github: "sunny/actor", branch: "main"
from actor.
Hi @sunny
I made a simple example extracted from README with the following configuration:
Ruby: 3.3.1
Rails: 7.1.3.2
Actor: 3.9.1
Actor-Rails: 1.0
OS: MacOS Sonoma
I created a simple Actor
class GreetUser < Actor
input :name
def call
"Have a wonderful day, #{name}!"
end
end
When I try to run the Actor on Rails console I get this output
OBS: I made a test using the main branch and the result was the same
from actor.
@sunny Hi. I checked version 3.9.1
. It still contains a large number of warnings. There is something simple:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `blank?`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `nil?`
But there is something more complicated when passing data to the fail!
method.
There are also critical cases that cause tests to fail. Here's an example:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `private_methods`
NoMethodError: undefined method `include?' for nil
Or an example with error
:
input :error, type: String, allow_nil: true
ArgumentError:
input `error` overrides `ServiceActor::Result` instance method
from actor.
@sunny Can you please tell about the purpose of the latest releases and what are your plans for the future?
We have projects with a huge number of services. All these services were implemented in different styles, use wrappers, etc., which was not prohibited or limited by the Service Actor.
Over the last few releases of Service Actor, we have been experiencing problems with updating the library of various types. Now we donβt have a clear understanding of how the library should work, what is considered wrong, what has limitations, etc.
from actor.
Hi @afuno! Sorry to hear about those frustrations.
The changes that impact you come from using a slimmed down version of a Result instead of relying on Rubyβs deprecated OpenStruct. Therefore a lot of methods that you depended on donβt exist anymore and we need to bring them back in. Iβm sorry about that.
Thank you for listing a few errors you are facing. Iβve noted:
blank?
method => allowed in #162nil?
method => allowed inmain
input :error
=> allowed inmain
private_methods
method => allowed in #162
Would you be willing to test your codebase against the add-blank-method
branch to see if there are any other underlying issues? The codebases I use with actor donβt have the same gems or wrappers so I didnβt get to see the same issues come up.
gem "service_actor", github: "sunny/actor", branch: "add-blank-method"
from actor.
Thank you for testing! Released as 3.9.2.
from actor.
Related Issues (20)
- alias_input is documented but unavailable HOT 1
- What about improving the README about testing? HOT 1
- Get "TypeError: exception class/object expected" error when update from 3.1.3 to 3.6 HOT 2
- Question / feature request: hooks around call? HOT 6
- Missing note on stubbing ServiceActor::Result HOT 4
- Can't set an hash as a default value for an input HOT 1
- Keep Zeitwerk as a development dependency only HOT 2
- Consider removing `OpenStruct` usage HOT 2
- Consider dropping support for unmaintained Ruby releases HOT 1
- Misleading `ServiceActor::ArgumentError` message under specific circumstances HOT 8
- Make Actor result + pattern matching more pleasant HOT 1
- Actor's output names collision with `Object`'s instance methods HOT 2
- Using `Kernel.tap` and `Kernel.then` via `ServiceActor::Result` receiver HOT 1
- Is `DefaultCheck` obsolete? HOT 4
- Release notes for 3.8.0 HOT 8
- [Proposal] Default outputs via `output_of` actor class method HOT 3
- Breaking changes on ServiceActor::Result `failure?` after dropping `ostruct` ??? HOT 5
- Repeated `play` execution on 3.9.0 HOT 2
- Actor play continues to call subsequent actors/interactors when one of the interactors fail
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actor.