Comments (7)
@Xuanwo we introduce Timestamp
to avoid this conversion.
Suppose we force Timestamp
as u64
and let users convert their own types to a u64
. It sounds reasonable for several cases. But a DateTime may fail to convert to u64
with UNIX epoch conversion if it exceeds. Also, a hybrid logic clock may hard to be convert into u64
. That's why we introduce Timestamp
abstraction - release users from considering all of this stuff.
from engula.
I made a try in this branch but believe there must be some best practices I miss - code should never be written as this XD.
Even I make Timestamp a simple Ord
bounded trait it brings <Timestamp: Ord + Display + Send + Clone + Copy>
everywhere. And I have to make two hacks.
- Introduce
'static +
to workaround lifetime gap in async context (which IMO is a unreasonable restriction for this concept). - Change
.unwarp_or(0)
to.unwrap
due toOrd
itself doesn't provide a reasonable "default" in "last_ts" context. We may introduce a new trait but I don't have a good background on it.
from engula.
Well I reduce the repetition a bit by factoring out:
pub trait Timestamp: Ord + Display + Send + Copy {}
impl<T> Timestamp for T where T: Ord + Display + Send + Copy {}
but the two questions above remain.
from engula.
I guess unwrap_or(0)
means unwrap_or_default
and add a trait bound Default
to overcome the first question. Here is the draft pull request #103 .
However, I don't still work well with lifetime, and am unsure whether Timestamp
is so basic and essential that we almost affect every abstraction in journal
- is it worth?
from engula.
Sorry for jumping into this discussion without more research.
As we will store the journal remotely, we need to consider how to ser/de the Timestamp
. Compared to using a trait, maybe we can use a struct here, and let users decide how to convert their Timestamp
into ours?
from engula.
As we will store the journal remotely, we need to consider how to ser/de the
Timestamp
. Compared to using a trait, maybe we can use a struct here, and let users decide how to convert theirTimestamp
into ours?
Can you elaborate a little bit? I don't see how a struct solves the problem here.
from engula.
Well, I got it. Thanks for explaining to me!
from engula.
Related Issues (20)
- Router lost updates because wake signal lost
- `GroupEngine` panics when fetching column family handle HOT 4
- the replica of the promoting group is removed as an orphan replica
- raftlog is not recycled in time, resulting in a long restart.
- assign two move_replica tasks within very short interval cause 2nd task block forever HOT 2
- fsm panics when apply merge stats
- client panics by ConnectionReset
- server panic with ServiceIsBusy HOT 3
- server panics because index out of range
- client router isn't clean the staled relation between shard and group.
- Infinite loop when entry size exceeds max io batch size
- client panics by `ConnectionReset`
- raft_engine::file_pipe_log::pipe_builder: The last log file is corrupted but ignored
- config should allow not present fields
- Refine `ServiceIsBusy` handing
- report migration state to root HOT 1
- `watch_state_changes` executes too long
- node pull shard cost too long HOT 1
- sometimes config change is ignored HOT 1
- Replace the underlying `RocksDB` of `StateEngine` to raft engine.
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 engula.