-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Feature management for #88 #141
Conversation
3a3a574
to
b440c8e
Compare
transaction.isResponseBodyPlainText = false | ||
} | ||
} | ||
return if (httpFeature.enabled) captureTransaction(request, chain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about keeping the same style for if else
everywhere?
For example, in the same file there are lines the conditions have braces for if
and else
cases (like on line 127).
I believe that it could improve readability a little bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can enable the MandatoryBracesIfStatements
detekt rule if you think it's the case
b440c8e
to
1f31b8a
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting here to give an high-level feedback on the PR.
First, thanks for taking the time to write it <3
I do like the DSL and I think it clarifies the configuration block a lot :)
On the other hand, I think we should try to:
-
Don't introduce a strong API change. We're changing the public API of Chucker (changes in the constructors of
ChuckerInterceptor
and similar classes) in a significant way. The problem is that, while the DSL is really elegant to call in Kotlin, that's not the same for Java users. Moreover, we just released3.x
and it's probably too early to do a strong API change. What do you folks think? I'd rather try to create a DSL that can be optionally used instead of the canonical API used to initialize Chucker. -
Rename
Feature
. I'd rather call itTab
orTabFeature
as the public API it exposes is clearly related to a Tab (e.g.newFragment
). AFeature
interface is probably still useful but it should probably be more abstract (e.g. onlyname
and andenabled
would suffice). This would allow for further extensions with features that are not necessarily tabs. -
Think about those
notImplemented()
in the-no-op
library. Historically we used to use zero values (e.g.override val name: Int = 0
). Is there a reason why now we're shifting our approach for the-no-op
library?
library/src/main/java/com/chuckerteam/chucker/internal/support/ClearDatabaseService.kt
Outdated
Show resolved
Hide resolved
interface Feature { | ||
@get:StringRes | ||
val name: Int | ||
val tag: Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tag is not really clear here what exactly it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to id
, is it clearer? Each feature should have a unique id
.
2444d3d
to
1f376bb
Compare
- maxContentLength - headersToRedact
959e164
to
5997246
Compare
5997246
to
b8ba648
Compare
@cortinico I still have to:
|
e8b4b8b
to
88f4a66
Compare
Awesome, please let me know if you need some support :) |
88f4a66
to
0a5cefe
Compare
ea5e371
to
cd4155e
Compare
@cortinico Done !
|
cce4ffd
to
fa092d0
Compare
fa092d0
to
4fe7207
Compare
@@ -48,8 +63,10 @@ class ChuckerCollector @JvmOverloads constructor( | |||
* @param transaction The HTTP transaction sent | |||
*/ | |||
internal fun onRequestSent(transaction: HttpTransaction) { | |||
if (!httpFeature.enabled) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add braces here for readability and to match other code lines, like below where condition with only one line in it has braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use braces when there is something to do.
My point of view is this is an early return, in order to do nothing. If I do nothing I have no braces 🤷♂
What do you think of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use braces when there is something to do.
Agree with @olivierperez
Also the style guide here https://developer.android.com/kotlin/style-guide#braces allows single-line if statements like:
if (condition) effect
@@ -61,8 +78,10 @@ class ChuckerCollector @JvmOverloads constructor( | |||
* @param transaction The sent HTTP transaction completed with the response | |||
*/ | |||
internal fun onResponseReceived(transaction: HttpTransaction) { | |||
if (!httpFeature.enabled) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion about braces as above.
@@ -21,6 +21,7 @@ artifacts { | |||
dependencies { | |||
implementation "com.squareup.okhttp3:okhttp:$okhttp3Version" | |||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" | |||
implementation "androidx.fragment:fragment:$fragmentVersion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could think about some other way of implementing feature management, which would allow to not include this dependency?
Thanks again for the big work @olivierperez I have to be honest, I'm a bit hesitant on merging this. I have the feeling the whole approach is a bit over engineered. My point of view is that is a bunch of extra code that we will have to maintain for a limited benefit. Ideally we should be able to have some sort of key-value storage used to store/retrieve configurations for specific features. Your approach is based on having a
Moreover, the DSL could be moved to a I generally have the feeling that we should simplify a bit the whole approach. On the other hand I strongly believe that we need some sort of modular infrastructure to make easy to Chucker extend. |
From my point of view, this is too much for Chucker at the moment. At the same time I should admit that a great amount of work was done here and thanks a lot for it, but we should probably do something like this later when we have more components, features, etc. |
Hi, thanks for the review and the comments and sorry for the delay. I propose to close this PR. BTW It was fun to develop it anyway |
Let's close it 👍 I anyway believe that we might come back to this topic at a certain topic and your PR could be used as material to kickoff the discussion again :) |
💎 Example
Kotlin
Java
📷 Screeshots
📄 Context
📝 Changes
FeatureManager
is an object that handle the Features systemFeature
interface describe what is a FeatureHttpFeature
andErrorsFeature
FeatureManager
to check if feature is enabled📎 Related PR
None
📝 How to test
🔮 Next steps