Comments (5)
/assignme
from openraft.
IMHO, the root cause of there being a lot of unwrap()
is other fields that have not yet been updated, such as matched
and last_applied
, which will be replaced with Option in future.
Returning an error is no better than an unwrap()
because at the top most level it has nothing to do but just panic.
My suggestion is:
- For now, just use
unwrap()
if necessary, to keep simplicity. - Find some ways to avoid using
unwrap()
. E.g., when comparing aa: LogId
andb: Option<LogId>
it would be more elegant by doing it withSome(a) >= b
, instead ofa >= b.unwrap()
.
from openraft.
I see, thanks for the advice!
from openraft.
👋 Thanks for opening this issue!
Get help or engage by:
/help
: to print help messages./assignme
: to assign this issue to you.
from openraft.
Hi~ I have an idea to discuss with you guys, make last_log_id an Option<LogId>
may introduce a lot of unwrap
operations, fortunately, PR #94 adds a return error type for many APIs, so I would like to add a helper function for RaftCore
:
impl RaftCore {
fn get_last_log_id(&self) -> Result<LogId, SomeErr>
}
use option.ok_or_else()
to convert None
to an Err.
What do you think? Also regarding the error type returned, should I add a new error type or return an existing error? Would like to hear your suggestions! @drmingdrmer @Veeupup
from openraft.
Related Issues (20)
- Feature: Monoio Runtime HOT 3
- Add sync primitives to `AsyncRuntime` trait HOT 1
- Add `AsyncRuntime::oneshot` HOT 2
- Propose stream-based Replication of Log Entries HOT 2
- Dynamic Cluster Membership HOT 5
- Ditch `async_trait` in favor of the official `async_fn_in_trait` feature HOT 6
- Refactor: Move `client_resp_channels` from `LeaderData` to new `tx_...`-field in `RaftCore` HOT 2
- Linearizable read with `ReadIndex` HOT 1
- about single node HOT 6
- Cluster Bootstrap and Node Initialization Sequence HOT 4
- Tracking issue for examples update HOT 1
- Update example `raft-kv-memstore` to use `storage-v2` HOT 2
- Update example `raft-kv-rocksstore` to use `storage-v2` HOT 1
- Move examples into the workspace HOT 1
- Install Snapshot v1 api HOT 3
- Observe state changes in a Raft node HOT 6
- Split metrics into data metrics and server metrics HOT 5
- About automatic remove HOT 3
- Backing up the WAL HOT 6
- Raft Core Panicking HOT 10
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 openraft.