• C#版Nebula客户端编译


    一、需求背景

    从Nebula的Github上可以发现,Nebula为以下语言提供了客户端SDK:

    nebula-cpp
    nebula-java
    nebula-go
    nebula-python
    nebula-node
    nebula-rust

    我们公司的业务开发语言是C#,但Nebula却没有提供C#版的客户端。

    由于Nebula支持源码编译,索性只好尝试动手编译一个。

    二、Thrift简介

    1.Thrift是Facebook在2007年贡献给Apache基金会的一个开源项目:https://thrift.apache.org/

    Thrift可以支持多种程序语言,例如:  C++, C#, Cocoa, Erlang, Haskell, Java, Ocami, Perl, PHP, Python, Ruby, Smalltalk。

    Thrift可以作为二进制的高性能的通讯中间件,支持数据(对象)序列化和多种类型的RPC服务

    2.Facebook自己也维护了一个Thrift,目前已经和Apache的Thrift差别较大,重写了编译器,重新实现了一个全异步的Thrift Server:https://github.com/facebook/fbthrift

    Facebook Thrift is not a distribution of Apache Thrift. 
    This is an evolved internal branch of Thrift that Facebook re-released to open source community in February 2014.
    Facebook Thrift was originally released closely tracking Apache Thrift but is now evolving in new directions.
    In particular, the compiler was rewritten from scratch and the new implementation features a fully asynchronous Thrift server.

    3.Nebula的客户端基于Thrift文件进行编译的,但是使用的Thrift编译器,不是Facebook贡献给Apache的那个Thrift,而是Facebook自己维护的那个Thrift,有点绕。

    4.Nebula提供的Thrift模板为:https://github.com/vesoft-inc/nebula-common/tree/master/src/common/interface

    三、编译前准备工作

    1.操作系统

      通过VMware搭建的本地CenOS 7,虚拟机与主机健通过NAT网络连接,内存8G,宿主机有梯子可以FQ

    2.安装依赖

    root# yum update
    root# yum install -y make 
                     m4 
                     git 
                     wget 
                     unzip 
                     xz 
                     readline-devel 
                     ncurses-devel 
                     zlib-devel 
                     gcc 
                     gcc-c++ 
                     cmake 
                     gettext 
                     curl 
                     redhat-lsb-core 
                     bzip2

    3.检查主机上的GCC和CMake版本是否正确

    root# g++ --version
    root# cmake --version

    发现版本不正确,并且git clone也不好使,只好手动下载2.0.1版本的nebula-common:https://github.com/vesoft-inc/nebula-common/tree/v2.0.1

    4.解压上述的nebula-common-2.0.1.zip解压,进入nebula-common-2.0.1根目录

     

    5.依次执行如下命令

    // 安装CMake。
    root# ./third-party/install-cmake.sh cmake-install
    
    // 启用CMake。
    root# source cmake-install/bin/enable-cmake.sh
    
    //opt目录添加写权限。
    root# sudo mkdir /opt/vesoft && sudo chmod -R a+w /opt/vesoft
    
    // 安装GCC。安装到opt目录需要写权限,用户也可以修改为其他目录。
    root# ./third-party/install-gcc.sh --prefix=/opt
    
    // 启用GCC。
    root# source /opt/vesoft/toolset/gcc/7.5.0/enable
    
    // 安装第三方依赖
    root# ./third-party/install-third-party.sh

    四、编译

    1.进入上述的nebula-common-2.0.1根目录

    2.依次执行命令

    root#cmake
    root#make

    3.查看基于Thrift模板生成的C#代码

    nebula-common-2.0.1/src/common/interface/gen-csharp/nebula

    五、后续工作

    目前只是根据Thrift模板生成了对应C#接口的定义和解析,还需要参考Nebula提供的Java的客户端代码,翻译成对应的C#代码

    六、参考文档

    https://docs.nebula-graph.com.cn/2.0.1/4.deployment-and-installation/1.resource-preparations/

  • 相关阅读:
    去掉字符串中的空格
    在线工具和云服务推荐
    Tomcat 8080端口被占用解决方法
    MySQL 相关总结
    去除Jsp页面空白行
    linux 常用命令
    最近面试Android的一些面试题
    Android动态加载Activity原理
    Android动态资源加载原理和应用
    利用DexClassLoader动态加载dex文件
  • 原文地址:https://www.cnblogs.com/liugh/p/15030242.html
Copyright © 2020-2023  润新知