溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何解決C#版Nebula客戶端編譯的問題

發(fā)布時間:2021-07-21 13:52:02 來源:億速云 閱讀:182 作者:小新 欄目:開發(fā)技術(shù)

小編給大家分享一下如何解決C#版Nebula客戶端編譯的問題,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

一、需求背景

從Nebula的Github上可以發(fā)現(xiàn),Nebula為以下語言提供了客戶端SDK:

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

我們公司的業(yè)務(wù)開發(fā)語言是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可以作為二進制的高性能的通訊中間件,支持?jǐn)?shù)據(jù)(對象)序列化和多種類型的RPC服務(wù)

2.Facebook自己也維護了一個Thrift,目前已經(jīng)和Apache的Thrift差別較大,重寫了編譯器,重新實現(xiàn)了一個全異步的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

如何解決C#版Nebula客戶端編譯的問題

三、編譯前準(zhǔn)備工作

1.操作系統(tǒng)

通過VMware搭建的本地CenOS 7,虛擬機與主機健通過NAT網(wǎng)絡(luò)連接,內(nèi)存8G,宿主機有梯子可以FQ

如何解決C#版Nebula客戶端編譯的問題

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

發(fā)現(xiàn)版本不正確,并且git clone也不好使,只好手動下載2.0.1版本的nebula-common:https://github.com/vesoft-inc/nebula-common/tree/v2.0.1

如何解決C#版Nebula客戶端編譯的問題

4.解壓上述的nebula-common-2.0.1.zip解壓,進入nebula-common-2.0.1根目錄

如何解決C#版Nebula客戶端編譯的問題

5.依次執(zhí)行如下命令

// 安裝CMake。
root# ./third-party/install-cmake.sh cmake-install

// 啟用CMake。
root# source cmake-install/bin/enable-cmake.sh

//opt目錄添加寫權(quán)限。
root# sudo mkdir /opt/vesoft && sudo chmod -R a+w /opt/vesoft

// 安裝GCC。安裝到opt目錄需要寫權(quán)限,用戶也可以修改為其他目錄。
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.依次執(zhí)行命令

root#cmake
root#make

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

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

如何解決C#版Nebula客戶端編譯的問題

以上是“如何解決C#版Nebula客戶端編譯的問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI