mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix warnings
This commit is contained in:
parent
7b00581c66
commit
ab2a997a77
@ -16,17 +16,17 @@ export 'revision.pbenum.dart';
|
||||
|
||||
class RevId extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RevId', createEmptyInstance: create)
|
||||
..aInt64(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'inner')
|
||||
..aInt64(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'value')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
RevId._() : super();
|
||||
factory RevId({
|
||||
$fixnum.Int64? inner,
|
||||
$fixnum.Int64? value,
|
||||
}) {
|
||||
final _result = create();
|
||||
if (inner != null) {
|
||||
_result.inner = inner;
|
||||
if (value != null) {
|
||||
_result.value = value;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
@ -52,13 +52,13 @@ class RevId extends $pb.GeneratedMessage {
|
||||
static RevId? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$fixnum.Int64 get inner => $_getI64(0);
|
||||
$fixnum.Int64 get value => $_getI64(0);
|
||||
@$pb.TagNumber(1)
|
||||
set inner($fixnum.Int64 v) { $_setInt64(0, v); }
|
||||
set value($fixnum.Int64 v) { $_setInt64(0, v); }
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool hasInner() => $_has(0);
|
||||
$core.bool hasValue() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearInner() => clearField(1);
|
||||
void clearValue() => clearField(1);
|
||||
}
|
||||
|
||||
class Revision extends $pb.GeneratedMessage {
|
||||
|
@ -23,12 +23,12 @@ final $typed_data.Uint8List revTypeDescriptor = $convert.base64Decode('CgdSZXZUe
|
||||
const RevId$json = const {
|
||||
'1': 'RevId',
|
||||
'2': const [
|
||||
const {'1': 'inner', '3': 1, '4': 1, '5': 3, '10': 'inner'},
|
||||
const {'1': 'value', '3': 1, '4': 1, '5': 3, '10': 'value'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `RevId`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List revIdDescriptor = $convert.base64Decode('CgVSZXZJZBIUCgVpbm5lchgBIAEoA1IFaW5uZXI=');
|
||||
final $typed_data.Uint8List revIdDescriptor = $convert.base64Decode('CgVSZXZJZBIUCgV2YWx1ZRgBIAEoA1IFdmFsdWU=');
|
||||
@$core.Deprecated('Use revisionDescriptor instead')
|
||||
const Revision$json = const {
|
||||
'1': 'Revision',
|
||||
|
@ -224,7 +224,7 @@ fn mk_acked_ws_message(revision: &Revision) -> WsMessageAdaptor {
|
||||
// let _ = wtr.write_i64::<BigEndian>(revision.rev_id);
|
||||
|
||||
let mut rev_id = RevId::new();
|
||||
rev_id.set_inner(revision.rev_id);
|
||||
rev_id.set_value(revision.rev_id);
|
||||
let data = rev_id.write_to_bytes().unwrap();
|
||||
|
||||
let data = WsDocumentData {
|
||||
|
@ -1,57 +0,0 @@
|
||||
use std::cmp::{max, min};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Interval {
|
||||
pub start: i64,
|
||||
pub end: i64,
|
||||
}
|
||||
|
||||
impl Interval {
|
||||
/// Construct a new `Interval` representing the range [start..end).
|
||||
/// It is an invariant that `start <= end`.
|
||||
pub fn new(start: i64, end: i64) -> Interval {
|
||||
debug_assert!(start <= end);
|
||||
Interval { start, end }
|
||||
}
|
||||
|
||||
pub fn start(&self) -> i64 { self.start }
|
||||
|
||||
pub fn end(&self) -> i64 { self.end }
|
||||
|
||||
pub fn is_before(&self, val: i64) -> bool { self.end <= val }
|
||||
|
||||
pub fn contains(&self, val: i64) -> bool { self.start <= val && val < self.end }
|
||||
|
||||
pub fn contains_range(&self, start: i64, end: i64) -> bool { !self.intersect(Interval::new(start, end)).is_empty() }
|
||||
|
||||
pub fn is_after(&self, val: i64) -> bool { self.start > val }
|
||||
|
||||
pub fn is_empty(&self) -> bool { self.end <= self.start }
|
||||
|
||||
pub fn intersect(&self, other: Interval) -> Interval {
|
||||
let start = max(self.start, other.start);
|
||||
let end = min(self.end, other.end);
|
||||
Interval {
|
||||
start,
|
||||
end: max(start, end),
|
||||
}
|
||||
}
|
||||
|
||||
// the first half of self - other
|
||||
pub fn prefix(&self, other: Interval) -> Interval {
|
||||
Interval {
|
||||
start: min(self.start, other.start),
|
||||
end: min(self.end, other.start),
|
||||
}
|
||||
}
|
||||
|
||||
// the second half of self - other
|
||||
pub fn suffix(&self, other: Interval) -> Interval {
|
||||
Interval {
|
||||
start: max(self.start, other.end),
|
||||
end: max(self.end, other.end),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn size(&self) -> i64 { self.end - self.start }
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
mod edit_actor;
|
||||
mod edit_doc;
|
||||
mod interval;
|
||||
mod open_handle;
|
||||
|
||||
pub use edit_actor::*;
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::document::helper::{DocScript, DocumentTest};
|
||||
use flowy_document::services::doc::{Document, FlowyDoc};
|
||||
use flowy_ot::core::Delta;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn sync_doc_insert_text() {
|
||||
|
@ -14,7 +14,7 @@ use flowy_user::services::user::UserSession;
|
||||
// use crate::helper::*;
|
||||
use crate::helper::{spawn_server, TestServer};
|
||||
use flowy_document::protobuf::UpdateDocParams;
|
||||
use flowy_ot::core::Delta;
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use serde::__private::Formatter;
|
||||
|
||||
|
@ -7,11 +7,11 @@ edition = "2018"
|
||||
[lib]
|
||||
name = "dart_ffi"
|
||||
# this value will change depending on the target os
|
||||
# for iOS it would be `rlib`
|
||||
# for Macos it would be `rlib`
|
||||
# for iOS it would be `cdylib`
|
||||
# for Macos it would be `cdylib`
|
||||
# for android it would be `c-dylib`
|
||||
# default rlib
|
||||
crate-type = ["rlib"]
|
||||
# default cdylib
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
|
@ -39,23 +39,23 @@ impl std::default::Default for RevType {
|
||||
#[derive(Clone, Debug, ProtoBuf, Default)]
|
||||
pub struct RevId {
|
||||
#[pb(index = 1)]
|
||||
pub inner: i64,
|
||||
pub value: i64,
|
||||
}
|
||||
|
||||
impl AsRef<i64> for RevId {
|
||||
fn as_ref(&self) -> &i64 { &self.inner }
|
||||
fn as_ref(&self) -> &i64 { &self.value }
|
||||
}
|
||||
|
||||
impl std::convert::Into<i64> for RevId {
|
||||
fn into(self) -> i64 { self.inner }
|
||||
fn into(self) -> i64 { self.value }
|
||||
}
|
||||
|
||||
impl std::convert::From<i64> for RevId {
|
||||
fn from(value: i64) -> Self { RevId { inner: value } }
|
||||
fn from(value: i64) -> Self { RevId { value } }
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RevId {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("{}", self.inner)) }
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("{}", self.value)) }
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Default, ProtoBuf)]
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use diesel::SqliteConnection;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_net::config::ServerConfig;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct RevId {
|
||||
// message fields
|
||||
pub inner: i64,
|
||||
pub value: i64,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
@ -43,19 +43,19 @@ impl RevId {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
// int64 inner = 1;
|
||||
// int64 value = 1;
|
||||
|
||||
|
||||
pub fn get_inner(&self) -> i64 {
|
||||
self.inner
|
||||
pub fn get_value(&self) -> i64 {
|
||||
self.value
|
||||
}
|
||||
pub fn clear_inner(&mut self) {
|
||||
self.inner = 0;
|
||||
pub fn clear_value(&mut self) {
|
||||
self.value = 0;
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_inner(&mut self, v: i64) {
|
||||
self.inner = v;
|
||||
pub fn set_value(&mut self, v: i64) {
|
||||
self.value = v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ impl ::protobuf::Message for RevId {
|
||||
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
|
||||
}
|
||||
let tmp = is.read_int64()?;
|
||||
self.inner = tmp;
|
||||
self.value = tmp;
|
||||
},
|
||||
_ => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
|
||||
@ -87,8 +87,8 @@ impl ::protobuf::Message for RevId {
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u32 {
|
||||
let mut my_size = 0;
|
||||
if self.inner != 0 {
|
||||
my_size += ::protobuf::rt::value_size(1, self.inner, ::protobuf::wire_format::WireTypeVarint);
|
||||
if self.value != 0 {
|
||||
my_size += ::protobuf::rt::value_size(1, self.value, ::protobuf::wire_format::WireTypeVarint);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
|
||||
self.cached_size.set(my_size);
|
||||
@ -96,8 +96,8 @@ impl ::protobuf::Message for RevId {
|
||||
}
|
||||
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
|
||||
if self.inner != 0 {
|
||||
os.write_int64(1, self.inner)?;
|
||||
if self.value != 0 {
|
||||
os.write_int64(1, self.value)?;
|
||||
}
|
||||
os.write_unknown_fields(self.get_unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
@ -138,9 +138,9 @@ impl ::protobuf::Message for RevId {
|
||||
descriptor.get(|| {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>(
|
||||
"inner",
|
||||
|m: &RevId| { &m.inner },
|
||||
|m: &mut RevId| { &mut m.inner },
|
||||
"value",
|
||||
|m: &RevId| { &m.value },
|
||||
|m: &mut RevId| { &mut m.value },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<RevId>(
|
||||
"RevId",
|
||||
@ -158,7 +158,7 @@ impl ::protobuf::Message for RevId {
|
||||
|
||||
impl ::protobuf::Clear for RevId {
|
||||
fn clear(&mut self) {
|
||||
self.inner = 0;
|
||||
self.value = 0;
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
@ -799,8 +799,8 @@ impl ::protobuf::reflect::ProtobufValue for RevType {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0erevision.proto\"\x1d\n\x05RevId\x12\x14\n\x05inner\x18\x01\x20\x01\
|
||||
(\x03R\x05inner\"\xa3\x01\n\x08Revision\x12\x1e\n\x0bbase_rev_id\x18\x01\
|
||||
\n\x0erevision.proto\"\x1d\n\x05RevId\x12\x14\n\x05value\x18\x01\x20\x01\
|
||||
(\x03R\x05value\"\xa3\x01\n\x08Revision\x12\x1e\n\x0bbase_rev_id\x18\x01\
|
||||
\x20\x01(\x03R\tbaseRevId\x12\x15\n\x06rev_id\x18\x02\x20\x01(\x03R\x05r\
|
||||
evId\x12\x1d\n\ndelta_data\x18\x03\x20\x01(\x0cR\tdeltaData\x12\x10\n\
|
||||
\x03md5\x18\x04\x20\x01(\tR\x03md5\x12\x15\n\x06doc_id\x18\x05\x20\x01(\
|
||||
|
@ -1,7 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message RevId {
|
||||
int64 inner = 1;
|
||||
int64 value = 1;
|
||||
}
|
||||
message Revision {
|
||||
int64 base_rev_id = 1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use bytes::Bytes;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use tokio::time::{interval, Duration};
|
||||
|
||||
use flowy_database::{ConnectionPool, SqliteConnection};
|
||||
|
@ -212,7 +212,7 @@ impl ClientEditDoc {
|
||||
server_rev_id,
|
||||
} = rx.await.map_err(internal_error)??;
|
||||
|
||||
if self.rev_manager.rev_id() >= server_rev_id.0 {
|
||||
if self.rev_manager.rev_id() >= server_rev_id.value {
|
||||
// Ignore this push revision if local_rev_id >= server_rev_id
|
||||
return Ok(());
|
||||
}
|
||||
@ -232,7 +232,7 @@ impl ClientEditDoc {
|
||||
|
||||
// save the revision
|
||||
let revision = Revision::new(
|
||||
server_rev_id.0,
|
||||
server_rev_id.value,
|
||||
local_rev_id,
|
||||
client_prime.to_bytes().to_vec(),
|
||||
&self.doc_id,
|
||||
@ -242,7 +242,7 @@ impl ClientEditDoc {
|
||||
|
||||
// send the server_prime delta
|
||||
let revision = Revision::new(
|
||||
server_rev_id.0,
|
||||
server_rev_id.value,
|
||||
local_rev_id,
|
||||
server_prime.to_bytes().to_vec(),
|
||||
&self.doc_id,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{errors::DocResult, services::doc::UndoResult};
|
||||
use flowy_ot::core::{Attribute, Delta, Interval};
|
||||
|
||||
use crate::entities::doc::{RevId, Revision};
|
||||
use crate::entities::doc::RevId;
|
||||
use bytes::Bytes;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
|
@ -1,20 +1,11 @@
|
||||
use crate::{
|
||||
entities::doc::{RevId, RevType, Revision, RevisionRange},
|
||||
entities::doc::{RevId, Revision, RevisionRange},
|
||||
errors::{internal_error, DocError},
|
||||
services::{
|
||||
doc::revision::store_actor::{RevisionCmd, RevisionStoreActor},
|
||||
util::RevIdCounter,
|
||||
ws::DocumentWebSocket,
|
||||
},
|
||||
};
|
||||
use flowy_infra::{
|
||||
future::ResultFuture,
|
||||
retry::{ExponentialBackoff, Retry},
|
||||
services::{doc::revision::store_actor::RevisionCmd, util::RevIdCounter, ws::DocumentWebSocket},
|
||||
};
|
||||
use flowy_infra::future::ResultFuture;
|
||||
use flowy_ot::core::Delta;
|
||||
use flowy_ws::WsState;
|
||||
use parking_lot::RwLock;
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
pub struct DocRevision {
|
||||
@ -77,7 +68,7 @@ impl RevisionManager {
|
||||
let (ret, rx) = oneshot::channel();
|
||||
let sender = self.rev_store.clone();
|
||||
let _ = sender.send(RevisionCmd::SendRevisions { range, ret }).await;
|
||||
let revisions = rx.await.map_err(internal_error)??;
|
||||
let _revisions = rx.await.map_err(internal_error)??;
|
||||
|
||||
unimplemented!()
|
||||
// Ok(())
|
||||
|
@ -1,12 +1,5 @@
|
||||
use crate::{
|
||||
entities::doc::{NewDocUser, RevId, Revision},
|
||||
errors::{DocError, DocResult},
|
||||
services::ws::DocumentWebSocket,
|
||||
sql_tables::RevState,
|
||||
};
|
||||
use flowy_infra::retry::Action;
|
||||
use futures::future::BoxFuture;
|
||||
use std::{future, sync::Arc};
|
||||
use crate::{entities::doc::Revision, errors::DocResult, services::ws::DocumentWebSocket, sql_tables::RevState};
|
||||
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
pub type Sender = oneshot::Sender<DocResult<()>>;
|
||||
|
@ -3,8 +3,7 @@ use bytes::Bytes;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use flowy_ws::WsState;
|
||||
use std::{collections::HashMap, convert::TryInto, sync::Arc};
|
||||
use tokio::sync::broadcast::error::RecvError;
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
pub(crate) trait WsDocumentHandler: Send + Sync {
|
||||
fn receive(&self, data: WsDocumentData);
|
||||
|
@ -8,7 +8,7 @@ use flowy_document::{
|
||||
use flowy_document::{entities::ws::WsDocumentData, errors::internal_error, services::ws::WsStateReceiver};
|
||||
use flowy_user::{errors::ErrorCode, services::user::UserSession};
|
||||
use flowy_ws::{WsMessage, WsMessageHandler, WsModule};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
pub struct DocumentDepsResolver {
|
||||
|
@ -19,7 +19,7 @@ use flowy_database::{
|
||||
use flowy_infra::kv::KV;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use flowy_sqlite::ConnectionPool;
|
||||
use flowy_ws::{WsController, WsMessage, WsMessageHandler, WsState};
|
||||
use flowy_ws::{WsController, WsMessageHandler};
|
||||
use parking_lot::RwLock;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
|
Loading…
Reference in New Issue
Block a user