flatbuffer implementation and usage.Need some suggestions - client-server

Can flatbuffer be used for server client communication?Previously i was using JSON, but do you think flatbuffer will be useful for communication where the response from server is big enough to create some delay in reaching the client side.
If flatbuffer is not recommended, then which one I can use?Is there any library that can reduce the size of response from server and send it to client side for efficient and fast communication?

One of the best way to learn how to use flatbuffer and also to know more about flatbuffers vs JSON. (How to use FlatBuffers?)
FlatBuffer Android Sample Application
This app shows how fast flat buffer works when we compare it with json.
How to start with flatBuffer
$ git clone https://github.com/google/flatbuffers.git
$ cd flatbuffers
* Run the command on the basis of your platform
$ cmake -G "Unix Makefiles"
$ cmake -G "Visual Studio 10"
$ cmake -G "Xcode"
* now build for your platform as usual. This should result in a flatc executable
* Now create your schema file with extension .fbs. Guide to write a schema can be found [here]("https://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html").And also have your sample json file.
$ ./flatc -j -b schema.fbs sample.json
* This will create few java file and one bin file. Java files are like model(POJO for flatBuffer) of your json.Place the java files in your application package and bin file in raw folder(bin file is only for testing as it is converted to byte that is to be passed to flatbuffer for testing).
* Now we have to get flatbuffer jar file.
$ cd flatbuffers
$ cd java
$ mvn install
This will download all the dependencies.
$ cd target
* Here we will get the flatbuffers-java-1.3.0-SNAPSHOT.jar file that we have to put it in your libs folder of android project.
* For rest you can see my (https://github.com/amitshekhariitbhu/FlatBuffer).
## Major steps:
* Prepare your schema.fbs.
* Have a sample json.
* Build flatBuffer google project to generate your java files to be used in main application.
* Generate java files.

Yes, a FlatBuffers message will typically be a lot smaller than the equivalent JSON, and it will be quicker to access.

Related

Creating a go binary as debian binary package for a custom repository

I am trying to package a binary written in Go as a debian/ubuntu binary package. This would be available for download from a custom web server and apt key.
I am - very - confused.
I looked at https://wiki.debian.org/Packaging/Intro?action=show&redirect=IntroDebianPackaging first. This looks like exhaustive, without wanting to say too complex.
What confuses me is that the file debian/rules contains a make command. But we don't have a Makefile, do I need to create one?
In fact I am at the debuild -us -uc step, and it obviously failed.
Then I saw this: https://askubuntu.com/a/251892 , where it says:
Avoid the Debian bureaucracy by just building the binary:
dpkg-buildpackage -b
I did that, and the command completed, but looking at the generated package there it doesn't contain any binaries, only a changelog.gz and a copyright file in the app folder below /usr/share/doc.
So I am lost, I have no idea which tutorial to follow here to build a binary custom package, which, btw, later will be available for download signed. Obviously it is my first debian/ubuntu package I am creating.
I'm currently working on a project written in go that is distributed as a .deb package in a repository.
I have to tell you that it is not easy to find documentation about it. I use fpm for that activity.
First create in a folder that represents your project on the destination computer. For example "/tmp/proj"
Inside that folder you must put everything you want to distribute in the package. For example, if your compiled binary is called "myapp" and you want to put it in "/usr/bin/", then you have to create the folder "/tmp/proj/usr/bin" and put in it the executable file with the permissions you will use.
This way with all the files you want to distribute.
Then create a script that you will use to generate the package:
PKG_NAME= application name, one word, lowercase
PKG_DESCRIPTION= Brief description of the package
PKG_VERSION= Version, in x.y.z format
PKG_RELEASE= Correlative number from 1 onwards
PKG_MAINTAINER= Your name and email. Format: "name" < email >
PKG_VENDOR= Your company name
PKG_URL= URL of your product
FPM_OPTS="-n $PKG_NAME -v $PKG_VERSION --iteration $PKG_RELEASE"
fpm -s dir -t deb ${FPM_OPTS} -f \
-maintainer "$PKG_MAINTAINER" \
--vendor "$PKG_VENDOR" \
--url "$PKG_URL" \
--description "$PKG_DESCRIPTION" \
--architecture "amd64" \
-C /tmp/proj \
.
And that's it!
Well, there's a lot to learn.

How to generate API Documentation using openapi-generator?

I'm new to the OpenAPI 3.0.0.
I have successfully created a java client library using an openapi-generator.
But OpenAPI Generator allows the generation of API client libraries (SDK generation), server stubs, documentation. So I want to know is there any commands or steps are available to generate HTML documentation and also to customize the documentation template.
Old question, but for those still bumping into it. OpenApi Generator can do generation of html documentation from your yaml or json definition of your API.
openapi-generator generate -i PathToMyInputDefinitionFile.yaml -g html -o /PathToOutputFolder
Where html is the generator you want to use. Other generators include dynamic-html and html2. Also can emit as markdown. See https://openapi-generator.tech/docs/generators/
If using Docker, a full example would look like this:
docker run --rm -v ${PWD}:/local openapitools/openapi-generator:tagname generate -i /local/input.yaml -g html -o /local
PWD is present working directory (current directory) in the host, which you are mapping on to /local in the container. Adjust 'tagname' to suit, from https://hub.docker.com/r/openapitools/openapi-generator/tags Adjust input.yaml to be your input file yaml definition of your API.

Bitbake recipe, copy in raw mode of huge set of different files

I have a huge set of files that I want to raw copy in my rootfs. However, do_rootfs always tries to compile / install some files not in raw mode but checking their dependencies (and therefore fails with no package provides /usr/local/bin/...).
I just want to copy executable and other sort of files in raw mode.
Any ideas?
As #jku pointed out, more details would be helpful. From the limited information using the following in your layer:
do_configure[noexec] = "1"
do_compile[noexec] = "1"
do_install[noexec] = "1"
Will do exactly what the name suggests; will not execute the particular function such as configuring, compiling or installing on the required object.

protoc not generating service stub files

I have just started playing with google proto. When I try to compile proto file present in proto-java example, it does not generate any grpc file.
proto file,
https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/hello_world.proto
terminal output,
rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc
--version libprotoc 3.0.0 rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc
--java_out=test/ -I../../grpc-java/examples ../../grpc-java/examples/src/main/proto/hello_world.proto
rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ ls -R test/
test/: io
test/io: grpc
test/io/grpc: examples
test/io/grpc/examples: helloworld
test/io/grpc/examples/helloworld: HelloRequest.java
HelloResponse.java HelloWorldProto.java
HelloRequestOrBuilder.java HelloResponseOrBuilder.java
Has anybody else faced this issue?
The command line you are showing does not enable the grpc plugin. You need to specify an _out argument for the grpc plugin, which enables the plugin and specifies where it should output files. Since the plugin is likely not in your PATH, you also need to tell protoc how to find the plugin with --plugin.
So you need to add two arguments:
--plugin=protoc-gen-grpc-java=path/to/protoc-gen-grpc-java --grpc-java_out=path/to/output/dir
For more info, see the gRPC compiler documentation.
You can add these option to your .proto (base on your language) to generate abstract services:
option cc_generic_services = true;
option java_generic_services = true;
option py_generic_services = true;
You can also add --plugin=EXECUTABLE option in your protoc cmd to use custom code generator plugin to generate code more specific to each system, rather than rely on the "abstract" services. Just like Eric's suggestion.

soapcpp2 can't generate soapClient.c file

I am trying to build a tr069 client using gsoap. I followed the instructions in the document but I could not get soapClient.c.
Here is the steps:
wsdl2h -c -o tr069.h cwmp-1-1.xsd --> this generate tr069.h
soapcpp2 -c tr069.h --> this only generates the following file:
ns1.nsmap, soapC.c soapH.h soapStub.h
According to the examples online and in the document, I am suppose to get file like soapClient.c
Does anyone knows why? I am using gsoap 2.8
Thanks.
The cwmp-1-1.xsd is only an XSD file. You do not have a WSDL defining the operations that normally are stored in soapClient.c. However, you can still use the XML root element serializers (see bottom part of tr069.h for instructions) over sockets etc.

Resources