您如何设计协作/共享文本编辑器:关键点如下 [英] How would you design a Collabritive/ Shareable Text Editor: Key points are given below

查看:108
本文介绍了您如何设计协作/共享文本编辑器:关键点如下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多个用户的读/写操作。
用户可以使编辑器只读,即仅会话的创建者写。
您应该能够共享当前会话的链接,以添加更多用户以同时进行工作。
应该是并发的(同步),并避免编辑冲突。建议这样做的方法。
请关注正确和可扩展的功能。
应该具有自动保存功能
编辑器应该在每次保存时都进行更改/编辑。
支持回滚到任何更改。
必须具有社交媒体的共享/类似功能。

Read/Write operations by multiple users. A user may be able to make the editor read only i.e only the creator of the session writes. You should be able to share the link of the current session to add more users to work on simultaneously. It should be concurrent(synchronization) and avoid editing conflicts. Suggest approach to do this. Please focus on a correct and scalable functionality. Should have auto save Editor should maintain changes/edits on each save. Support rollback to any change. Must have share/like functionality for social media.

我能够提供以下内容,需要帮助识别类来为此构建类图:

I was able to come with the following, need help identifying classes to build a class diagram for this:

这将是客户端服务器实现。

It will be a client server implementation.

对于网站,客户端可以用HTML5和Javascript编写。我们可以使用其他javascript框架来满足特定要求(例如angularjs)。

For website, client can be written in HTML5 and Javascript. We can use additional javascript frameworks for specific requirements(eg. angularjs).

对于发送请求,可以使用两种方法:
1.请求/响应
-每秒发送请求
2.长池
-向服务器发出永无止境的http请求并通过它进行通信。此方法将比以前的方法更快,因为不会发出多个http请求。

For sending request two methods are available: 1. Request/Response -- Sending request every second 2. Long pooling -- Make a never ending http request to server and communicate through it. This method will be way faster that earlier one because multiple http request will not be made.

它是客户端以固定间隔(1秒)将更改发送到服务器的工作。 )。
它的工作是客户端了解其他用户所做的更改并将其显示给当前用户。

Its the work of client to send the changes to server on fixed interval (1 second). Its the work of client to understand the changes done by other users and display the same to current user.

服务器将公开一个将使用的API到
-获取当前文档
-SendUpdate请求,其响应将包含其他用户对同一文档所做的修改。我们将尝试捕获增量并在客户端表示更改。

Server will be expose an API which will be used to -- Get current document -- SendUpdate request whose response will contain modification done by other users on same document. We will try and capture the delta and represent the changes on the client side.

服务器堆栈必须非常快(.node.js或golang会适合这种情况。要求),因为其响应时间非常短。
数据应该存储在内存中,我们可以使用Redis来存储数据。我们可以按间隔或显式保存请求,也可以将数据保存在文件系统上,也可以保存在内存数据库中。

Server Stack has to be very fast(.node.js or golang will be suitable for such requirement) because of its very short response time. Data should be stored in memory, we can use Redis to store data. We can on intervals or on explicit save requests, save data on the file system or non in memory databases also.

每个请求都将包含客户端所做的一组更改。
这些更改将与时间戳一起保存在Redis中。
我们不会将整个文件存储在数据库中,我们只会存储历史更改。由于redis是基于内存的,因此从存储的更改集中计算最终文档将花费很少的资源。

Every request will contain set of changes made by client. These changes will be saved in Redis along with timestamp. We wont be store whole file in database, we will just store historic changes. As redis is based on memory, it will take very little resource to compute final document from set of stored changes.

对于每个文档,都有唯一的ID与之关联。唯一ID应该足够长。
您可以为记事本创建一个URL,例如example.com/notepad/{unique-id}
这将加载客户端,然后加载与该唯一ID相关的文档。

For every document there will be unique id associated with it. Unique id should be long enough. You can create a url for notepads like example.com/notepad/{unique-id} This will load the client and then load the document related to that unique id.

对于每个请求,将发送此唯一ID以标识用户正在编辑哪个文档。
保存
每一次更改都将发送到数据库时,它将自动保存。

For every request this unique id will be send to identify which document is being edited by user. Save As every change is being sent to database, it will be auto saved.

还原
您可以将历史数据保留在其中AngularJs。如果要在会话之间保持持久性,请将数据存储到文件系统。
您还可以使用API​​从服务器检索历史信息。

Revert You can keep historic data in AngularJs. If you want persistence between sessions, store data to file system. You can also retrieve historic information from server using API. Which can be undone.

Facebook共享
我们还可以使用FB graph api在用户中发布链接;时间轴或Facebook公开sharer.php网址,

Facebook Share We can also use FB graph api to post link in user;s timeline or Facebook exposes a sharer.php url, which can be used to share Post / Share a link in user's timeline.

可伸缩性
我们可以使用基于云的可伸缩解决方案(例如Mmazon AWS EC2实例)来实现此功能。解。我们可以将Web服务器保留在负载均衡器之后。
我们必须将redis保留为单独的(大型)ec2实例。负载均衡器后面可以有多个Web服务器。
所有这些都将与Redis实例进行通信。
我们可以在CDN中保留诸如css和js之类的静态数据(S3后面的AWS CloudFront)

Scalability We can use cloud based scalable solutions like Mmazon AWS EC2 instances to implement this solution. We can keep webserver behind a load balancer. We have to keep redis as separate (large) ec2 instance. There can be multiple webserver behind load balanacer. All of them will be communicating with Redis instance. We can keep static data like css and js in CDN (AWS CloudFront behind S3)

推荐答案

客户端服务器实现。

将向服务器公开一个API,该API将用于

-获取当前文档

-SendUpdate请求,其响应将包含其他用户对同一文档进行的修改

It will be a client server implementation.
Where server will be expose an API which will be used to
-- Get current document
-- SendUpdate request whose response will contain modification done by other users on same document

它是客户端以固定间隔(例如1秒钟)将更改发送到服务器的工作。
它是客户端了解其他用户所做的更改并将其显示给当前用户的工作。

Its the work of client to send the changes to server on fixed interval (say 1 second). Its the work of client to understand the changes done by other users and display the same to current user.

对于网站,客户端可以用HTML5和Javascript。您可以将AngularJs用作javascript框架。

对于发送请求,有两种方法可用:

1.同步

-每秒发送请求< br>
2.长时间缓冲

-向服务器发出永无止境的http请求并通过它进行通信。此方法将比以前的方法更快,因为不会发出多个http请求。

For website, client can be written in HTML5 and Javascript. You can use AngularJs as javascript framework for the same.
For sending request two methods are available:
1. Synchronization
-- Sending request every second
2. Long pooling
-- Make a never ending http request to server and communicate through it. This method will be way faster that earlier one because multiple http request will not be made.

服务器堆栈必须非常快。 node.js或golang因其响应时间非常短而适合于此类要求。

数据应存储在内存中,您可以使用Redis来存储数据。

Server Stack has to be very fast. node.js or golang will be suitable for such requirement, because of its very short response time.
Data should be stored in memory, you can use Redis to store data.

每个请求都将包含客户端所做的一组更改。

这些更改将与时间戳一起保存在Redis中。

您不会将整个文件存储在数据库中,而应该存储历史更改。由于redis基于内存,因此只需很少的资源即可从一组存储的更改中计算最终文档。

Every request will contain set of changes made by client.
These changes will be saved in Redis along with timestamp.
You wont store whole file in database, you should just store historic changes. As redis is based on memory, it will take very little resource to compute final document from set of stored changes.

这篇关于您如何设计协作/共享文本编辑器:关键点如下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆