简体   繁体   English

这个Scala Perl / Python架构是否有意义

[英]Does this Scala Perl/Python architecture make sense

In another question I asked for "the best" language for a certain purpose. 在另一个问题中,我为某种目的要求“最好的”语言。 Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. 实现这个目标有点太多了,我简化了我的想法:)但是有非常有用的语言提示。 So I decided on Scala for the desktop-app and consider between Perl and Python on the webserver. 所以我决定在桌面应用程序上使用Scala,并考虑在Web服务器上使用Perl和Python。

I want to program something like an asynchronous chat (little bit like an email). 我想编写类似异步聊天(有点像电子邮件)的东西。 So you start your program pick your name and add a friend with his unique id. 所以你开始你的程序选择你的名字,并添加一个他的唯一ID的朋友。 Then you can write him a simple message and when your friends start up his pc, launches the "chat.exe" he receives the mail (internet is required) and is able to answer. 然后你可以给他写一个简单的消息,当你的朋友启动他的电脑时,启动他收到邮件的“chat.exe”(需要互联网)并且能够回答。 No special functions, smiley's or text formatting, just simple for learning purpose. 没有特殊功能,笑脸或文字格式,只是为了学习目的。

My concept is: Use Scala for the "chat.exe" (Or is just a "chat.jar" possible?) which communicates via SOCKET with a Perl/Python Framework which handles the requests. 我的概念是:使用Scala作为“chat.exe”(或者只是“chat.jar”可能吗?),它通过SOCKET与处理请求的Perl / Python框架进行通信。 So you type "Hello there" and click on send. 所以你输入“Hello there”并点击发送。 This message is transfered via SOCKET to a Perl/Python script which reads the request an put this message in a MySQL database. 此消息通过SOCKET传输到Perl / Python脚本,该脚本读取请求将此消息放入MySQL数据库。 On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl/Python script transfer the message. 在另一方面,您朋友的chat.exe检查新消息,如果有消息,则Perl / Python脚本会传输消息。 Also via SOCKET. 也通过SOCKET。

Do you think this works out? 您认为这可行吗? Is SOCKET appropriate and fits in? SOCKET适合适合吗? Or perhaps REST? 或者也许是REST? But I think for REST-Requests you have to use the URI (http://example.com/newmessage/user2/user3/Hi_how_are_you). 但我认为对于REST-Requests,您必须使用URI(http://example.com/newmessage/user2/user3/Hi_how_are_you)。 This looks very unsecure. 这看起来非常不安全。

Look forward to your comments! 期待您的评论!

Have a nice day, 祝你今天愉快,

Kurt 库尔特

If you ask me, I think Scala is most suitable for the server side. 如果您问我,我认为Scala最适合服务器端。 Scala runs on the JVM and Java has a really big ecosystem at the server side. Scala在JVM上运行,Java在服务器端有一个非常大的生态系统。 You have a big variety of application servers for every taste (tomcat, jetty, glassfish, etc.). 你有各种各样的应用程序服务器(tomcat,jetty,glassfish等)。

Chat is a classical use case for actors. 聊天是演员的经典用例。 I think Akka can inspire you in this area. 我认为Akka可以在这个领域激励你。

You can use wonderful Scala web frameworks like Lift. 您可以使用精美的Scala Web框架,例如Lift。 You can even make a web-based chat. 您甚至可以进行基于网络的聊天。 Here is an example of a chat application that uses comet (server push): 这是使用彗星(服务器推送)的聊天应用程序的示例:

http://demo.liftweb.net/chat http://demo.liftweb.net/chat

About REST: If you feel that it's not secure, then 关于REST:如果你觉得它不安全那么

  1. Use HTTPS to communicate with server 使用HTTPS与服务器通信
  2. In your example, your intent is to put the message to the server (at least that is how I understood it), so most probably you want to use PUT requests, and in this case the message text would be in the POST request body. 在您的示例中,您的意图是将消息放入服务器(至少这是我的理解),因此很可能您希望使用PUT请求,在这种情况下,消息文本将位于POST请求正文中。

Use Scala for the "chat.exe" (Or is just a "chat.jar" possible?) 使用Scala作为“chat.exe”(或者只是“chat.jar”可能吗?)

Step 1. Figure that out. 步骤1.图出来。 Actually write some stuff and see what you can build. 实际写一些东西,看看可以做什么。

which communicates via SOCKET with a Perl/Python Framework which handles the requests. 它通过SOCKET与处理请求的Perl / Python框架进行通信。

Not meaningful. 没意义。 All internet communication is done with sockets. 所有的Internet通信都是通过套接字完成的。 Leave this sentence out and you don't lose any meaning. 忽略这句话,您不会失去任何意义。

This message is transfered via SOCKET to a Perl/Python script which reads the request an put this message in a MySQL database. 此消息通过SOCKET传输到Perl / Python脚本,该脚本读取请求将此消息放入MySQL数据库。

A little useful information. 一些有用的信息。 Sockets, however, go without saying. 然而,套接字不言而喻。

On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl/Python script transfer the message. 在另一方面,您朋友的chat.exe检查新消息,如果有消息,则Perl / Python脚本会传输消息。 Also via SOCKET. 也通过SOCKET。

Right. 对。 Sockets, again, don't mean much. 同样,套接字并不意味着什么。

On top of sockets there are dozens of protocols. 在套接字之上,有数十种协议。 FTP, Telnet, HTTP, SMTP, etc., etc. FTP,Telnet,HTTP,SMTP等,等等。

Step 2 is to figure out which protocol you want to use. 步骤2是弄清楚您要使用哪种协议。 REST, by the way is a particular use of HTTP. 顺便说一句,REST是HTTP的一种特殊用途。 You should really, really look very closely at HTTP and REST before dismissing them. 在关闭它们之前,您应该非常仔细地仔细研究HTTP和REST。

This looks very unsecure 这看起来非常不安全

Not clear why you're saying this. 不清楚你为什么这么说。 I can only guess that you don't know about HTTP security features. 我只能猜测您对HTTP安全功能一无所知。


A lazy programmer might do this. 懒惰的程序员可能会这样做。

  1. Install Python, Django, MySQL-Python and Piston. 安装Python,Django,MySQL-Python和Piston。

  2. Define a Django Model, configure the defaults so that model is exposed as a secure RESTful set of services. 定义Django模型,配置默认值,以便将模型公开为安全的RESTful服务集。

That's sort of it for the server side message GET, POST, PUT and DELETE are all provided by Django, Piston and the Django ORM layer. 服务器端消息GET,POST,PUT和DELETE都由Django,Piston和Django ORM层提供。 Authentication can be any of a variety of mechanisms. 身份验证可以是各种机制中的任何一种。 I'm a big fan of HTTP Digest authentication. 我是HTTP摘要认证的忠实拥护者。

要实现类似的东西,你需要通过一个MQ系统,比如ActiveMQ,而不是使用普通的套接字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM