Square Wire Service Implementation - protocol-buffers

I'm trying to learn about grpc and protocol buffers while creating a test app using square's wire library. I've got to the point of generating both client and server files but I got stuck in creating a server side app. The documentation is too simple and the examples in the library have to much going on.
Can anyone point out what are the next steps after generating the files?
Thanks.

I'm not sure what language your are using, but each gRPC language has similar set of examples. For example, for a simple server-side app, you can find the Python example at https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_server.py

Related

One-click OpenAPI/Swagger build architecture for backend server code

I use swagger to generate both client/server api code. On my frontend (react/ts/axios), integrating the generated code is very easy: I make a change to my spec, consume the new version through NPM, and immediately the new API methods are available
On the server side, however, the process is a lot more janky. I am using java, and I have to copy and paste specific directories over (such as the routes, data types etc) and a lot of the generated code doesn't play nice with my existing application (in terms of imports etc). I am having the same experience with a flask instance that I have.
I know that comparing client to server is apple to oranges, but is there a better way to construct a build architecture so that I don't have to go through this error prone/tedious process every time? Any pointers here?

How to respond to ajax calls on the server side?

I have been working on a mobile app that sends an ajax call to the server and waits for a response from the server in json format.
I am wondering from the server side, how to respond to an ajax call? Could someone give me an example in code?
I check the server code of my project (written by other members of the team) and could not understand it. I can only see it is written in java and also some keywords such as apache, springframework, etc pop up. I am a total newbie for server side programming and I want to learn more about it. Could someone give me some tips on how to get started with those as well? How does a server work? Is it just like responding to various request? What language could you use to build it and what is Apache? I know this looks like a lot of questions so probably I need to get some basic knowledge first. Any help/tips/suggestions on readings is appreciated.
This is kind of a broad question, as there are a lot of different server-side technologies that can handle server side AJAX requests, but if you want to go the Java route, using Spring Framework makes it very easy.
Spring Framework is a large open-source Enterprise Java framework that has a variety of features which entire books rarely even cover.
(Apache is an open-source project that contains over a hundred different sub-projects, the most popular being a web server.)
Spring does have some specific tools to handle REST calls. Assuming your AJAX is making a REST call (which is what it sounds like), and your project is already using Spring framework, it is fairly straightforward (assuming you already know Java). The Spring framework handles all the hard stuff for you. There are a few different ways to do this using Spring, but check out this link for creating a simple REST service:
https://spring.io/guides/gs/rest-service/
Another route would be to look into PHP, which is a server-side scripting language. With PHP, you can handle AJAX requests without the need for an application server (most basic web servers speak PHP). There are plenty of good resources for this, but one of my favorites is http://www.tutorialspoint.com/php/
BTW - the TutorialsPoint site is great for Java and Spring as well

Exporting data from Ada application with websocket

I'm developing a scholar project where I have a core written in Ada language that generates data information.
As requested by the project, I need to send all the new produced information, with a certain period, to a remote webserver via websocket.
In javascript language is really easy to connect to a web socket:
var exampleSocket = new WebSocket("ws://www.example.com/socketserver", "protocolOne");
I would be able to execute a similar command in Ada, is it possible?
May be possible to workaround the problem calling an html page (with GET parameters) containing javascript code so that this page manages the websocket with remote webserver?
For those still looking for this answer; AWS now supports websockets...
https://docs.adacore.com/aws-docs/aws/high_level_services.html#websockets
Both AWS and Black has supports websockets. AWS is the most mature of the two, so I suggest that you use that.

Dummies tutorial for Websocket in tomcat8 server and client

My first post.
I have experience of basic java servlet and jsp and have got my webpage implemented in tomcat7.
Regarding Websocket, I am finding difficult to build understanding of how to implement it, i want to use tomcat8 implementation of websocket api and uplift my webpage (jsp, java, jquery, tomcat7) to use the websocket features, have not been able to find the the tutorial that can guide me through, something like hello world example. any pointers (sample codes, tutorials)?
have tried to understand tomcat8 examples but not understanding them at all
You need to understand that you don't just "add" WebSocket to an existing web application.. to make it faster, better, cheaper, more scalable, etc. Instead, you have to completely re-architect the web-layer of the application to take advantage of its capabilities.
I suggest that you first read a lot about WebSocket and what the whole idea is before you try to write any code, using Tomcat or any other WebSocket-capable server.
Nick Williams has a forthcoming book that appears to cover everything in the web application world, and as I understand it, will have a great deal of information about WebSocket-based code. You will unfortunately have to wait until March 2013 (at least) to use that particular book.
I'm sure there are similar books available, or even online tutorials to help get you started using WebSocket. Just be aware that switching to WebSocket isn't some simple configuration option: it's a very disruptive change to any existing web application.

Protobuf in windows 8 app serialization or generating code not working

I need use protobuf in my windows store app and I use this Protobuf port but when I generate classes from proto file seen like not full because I dont have access to .newBuilder()... nad if I use p:lightFramework I still cannot work with .newBuilder()... Anyone can help?
Part of generated code without light framework options
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=#"Person")]
Part of generated code with light framework options
[global::ProtoBuf.ProtoContract(Name=#"Person")]
Problem is there:(.newBuilder() is not recognized
CP.ConnectionResponse respp = CP.ConnectionResponse.newBuilder()...
You seem to be using two different libraries at once; in particular, you seem to be following the instructions for protobuf port, but actually using protobuf-net. These are two different libraries, connected only in so much as:
they both target .NET
they both serialize/deserialize protobuf data
To add context - this is a bit like using JSON.NET but following the instructions for ServiceStack.Text: both can serialize/deserialize JSON, but the API is different.
You need to decide which library you want to use, and follow the instructions for that implementation.
As an aside: for the best performance on a store app / windows phone app with protobuf-net, you may also want to consider using the precompiler - but you should be able to get it working (for a proof-of-concept etc) without this.

Resources