-
Notifications
You must be signed in to change notification settings - Fork 121
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
Provide the fluent API for CentralDogma client #651
Conversation
Codecov Report
@@ Coverage Diff @@
## master #651 +/- ##
============================================
+ Coverage 69.87% 70.09% +0.21%
- Complexity 3298 3399 +101
============================================
Files 333 349 +16
Lines 13136 13464 +328
Branches 1425 1448 +23
============================================
+ Hits 9179 9437 +258
- Misses 3081 3151 +70
Partials 876 876
Continue to review full report at Codecov.
|
a7f0c4e
to
74309d3
Compare
This is ready for review. 😉 |
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.
Looks fluent!
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRequestPreparation.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaFilesRequest.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaCommitRequest.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRequestPreparation.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRequestPreparation.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRequestPreparation.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRequestPreparation.java
Outdated
Show resolved
Hide resolved
### Motivation - line#532 - To-Do of line#610 ### Modifications - Put value of `notify-entry-not-found` on `Prefer` request header to get error that entries are not found on watching file/repository - Propagate error that entries are not found into `Watcher#initialValueFuture` ### Result - You can get error on watching file/repository if the entry doesn't exist.
Motivation: I found out while I implementing line#651. The child watcher created via `Watcher#newChild(mapper)` executes the specified mapper every time when a listener is notified. If there are 1000 listeners, mapper is called 1000 times. This could be a problem if the mapper has a haevy logic. Modifications: - Execute mapper onle once when the entry is chaned. - Add `Watcher.newWatcher(Function, Executor)` that executes the mapper using the executor. Result: - The mapper `Function` of a Child watcher is executed only once when the child watcher get notified.
Motivation: I found out while I implementing line#651. The child watcher created via `Watcher#newChild(mapper)` executes the specified mapper every time when a listener is notified. If there are 1000 listeners, mapper is called 1000 times. This could be a problem if the mapper has a haevy logic. Modifications: - Execute mapper onle once when the entry is chaned. - Add `Watcher.newWatcher(Function, Executor)` that executes the mapper using the executor. Result: - The mapper `Function` of a Child watcher is executed only once when the child watcher get notified.
Motivation: I found out while I implementing line#651. The child watcher created via `Watcher#newChild(mapper)` executes the specified mapper every time when a listener is notified. If there are 1000 listeners, mapper is called 1000 times. This could be a problem if the mapper has a haevy logic. Modifications: - Execute mapper onle once when the entry is chaned. - Add `Watcher.newWatcher(Function, Executor)` that executes the mapper using the executor. Result: - The mapper `Function` of a Child watcher is executed only once when the child watcher get notified.
Motivation: I found out while I implementing line#651. The child watcher created via `Watcher#newChild(mapper)` executes the specified mapper every time when a listener is notified. If there are 1000 listeners, mapper is called 1000 times. This could be a problem if the mapper has a haevy logic. Modifications: - Execute mapper onle once when the entry is chaned. - Add `Watcher.newWatcher(Function, Executor)` that executes the mapper using the executor. Result: - The mapper `Function` of a Child watcher is executed only once when the child watcher get notified.
Motivation: I found out while I implementing line#651. The child watcher created via `Watcher#newChild(mapper)` executes the specified mapper every time when a listener is notified. If there are 1000 listeners, mapper is called 1000 times. This could be a problem if the mapper has heavy logic. Modifications: - Execute mapper only once when the entry is changed. - Add `Watcher.newWatcher(Function, Executor)` that executes the mapper using the executor. Result: - The mapper `Function` of a Child watcher is executed only once when the child watcher gets notified.
…tern & address comments by @ikhoon
e5fb6f1
to
7b4e04d
Compare
@di-seo Please, let me know if there's anything we can improve. 😄 |
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.
The overall API looks really nice! 🙇 👍 Left some minor questions on the Watcher
implementation 🙏
client/java/src/main/java/com/linecorp/centraldogma/client/MappingWatcher.java
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/internal/Jackson.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/MappingWatcher.java
Show resolved
Hide resolved
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 left some comments.
I look forward to this changes. :)
client/java/src/main/java/com/linecorp/centraldogma/client/WatchFilesRequest.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/DefaultWatcher.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogmaRepository.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatcherOptionsBuilder.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/Watcher.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
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.
Mostly looks good.
client/java/src/main/java/com/linecorp/centraldogma/client/AbstractWatcher.java
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CommitRequest.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatchRequest.java
Outdated
Show resolved
Hide resolved
@Override | ||
protected void scaffold(CentralDogma client) { | ||
client.createProject("foo").join(); | ||
client.createRepository("foo", "bar").join(); |
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.
Now, it might be natual that client.createRepository("foo", "bar")
returns a CompletableFuture<CentralDogmaRepository>
, although it is a breaking change. 😅
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.
Let me do that in the following PR. 😅
client/java/src/main/java/com/linecorp/centraldogma/client/FileRequest.java
Show resolved
Hide resolved
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.
Overall looks good! Left some minor comments 🙏
common/src/main/java/com/linecorp/centraldogma/common/DefaultPathPattern.java
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogma.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/CentralDogma.java
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatchRequest.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatchRequest.java
Outdated
Show resolved
Hide resolved
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.
Left a minor question, but overall looks good to me! Thank you @minwoox 🙇 👍 🙇
client/java/src/main/java/com/linecorp/centraldogma/client/MappingWatcher.java
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatcherRequest.java
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/WatcherRequest.java
Show resolved
Hide resolved
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.
client/java/src/main/java/com/linecorp/centraldogma/client/Watcher.java
Outdated
Show resolved
Hide resolved
client/java/src/main/java/com/linecorp/centraldogma/client/Watcher.java
Outdated
Show resolved
Hide resolved
Thanks, reviewers for the valuable comments. 🙇♂️ |
Motivation: We introduced `CentralDogmaRepository` class in line#651 and it would be nice if we return it from `centralDogma.createRepository(...)` so users can chain the next call. ```java dogma.createRepository("foo", "bar) .join() .commit(...) .push(); ``` Modifications: - Change to return `CentralDogmaRepository` from `centralDogma.createRepository(...)` and `centralDogma.unremoveRepository(...). - Fix flaky test in `WatchTest`.` Result: - (Breaking) `createRepository` and `unremoveRepository` from `CentralDogma` now returns `CentralDogmaRepository`.
…662) Motivation: We introduced `CentralDogmaRepository` class in #651 and it would be nice if we return it from `centralDogma.createRepository(...)` so users can chain the next call. ```java dogma.createRepository("foo", "bar) .join() .commit(...) .push(); ``` Modifications: - Change to return `CentralDogmaRepository` from `centralDogma.createRepository(...)` and `centralDogma.unremoveRepository(...). - Fix flaky test in `WatchTest`. Result: - (Breaking) `createRepository` and `unremoveRepository` from `CentralDogma` now returns `CentralDogmaRepository`.
Motivation:
Currently,
CentralDogma
client has a bunch of methods that take a bunch of parameters.It makes it harder to add another optional parameter to the existing methods because we need to add another pair of existing methods. For example:
Modifications:
PathPattern
interface to pass as the parameter instead of String.CentralDogma.forRepo(...)
method that returnsCentralDogmaRepository
.Result:
CentralDogma
client are deprecated. Use fluent APIs.