example: Add grpc client deps

This commit is contained in:
Eishun Kondoh 2018-10-10 17:45:18 +09:00
parent e8a02cdd9d
commit b9f353809d
8 changed files with 142 additions and 5 deletions

View file

@ -22,3 +22,4 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
evpn_router-*.tar
/priv/

View file

@ -7,23 +7,32 @@ defmodule EvpnRouter.MixProject do
version: "0.1.0",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
compilers: [:rustler] ++ Mix.compilers,
rustler_crates: rustler_crates(),
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
extra_applications: [:logger, :grpc, :tres],
mod: {EvpnRouter.Application, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
{:tres, path: "../../../tres"},
{:rustler, github: "hansihe/rustler", sparse: "rustler_mix"},
{:grpc, github: "tony612/grpc-elixir"},
{:ranch, "~> 1.6.0", override: true},
]
end
defp rustler_crates do
[evpn_router: [path: "native/gobgp", mode: rustc_mode(Mix.env)]]
end
defp rustc_mode(:prod), do: :release
defp rustc_mode(_), do: :debug
end

View file

@ -0,0 +1,38 @@
%{
"bbmustache": {:hex, :bbmustache, "1.3.0", "2010adae78830992a4c69680115ecd7d475dd03a72c076bbaddccbf2d4b32035", [:rebar3], [], "hexpm"},
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
"cf": {:hex, :cf, "0.2.2", "7f2913fff90abcabd0f489896cfeb0b0674f6c8df6c10b17a83175448029896c", [:rebar3], [], "hexpm"},
"cowboy": {:git, "https://github.com/ninenines/cowboy.git", "c998673eb009da2ea4dc0e6ef0332534cf679cc4", []},
"cowlib": {:hex, :cowlib, "2.6.0", "8aa629f81a0fc189f261dc98a42243fa842625feea3c7ec56c48f4ccdb55490f", [:rebar3], [], "hexpm"},
"cth_readable": {:hex, :cth_readable, "1.4.0", "f51362e3d365b14de5aed7e98166e0643f38d004af9750369d8f90e9f470fcc7", [:rebar3], [{:cf, "~>0.2.1", [hex: :cf, repo: "hexpm", optional: false]}], "hexpm"},
"dep_http2_client": {:git, "https://github.com/Bluehouse-Technology/http2_client", "8a6faf3ef1e0f3bb480d52d34ef5181258e99302", [branch: "master"]},
"elixir_make": {:hex, :elixir_make, "0.1.0", "b5a40367dce0ec15db916a9bcdfee189eebb536a13b814246e2551bcdb0c7031", [:mix], [], "hexpm"},
"eovsdb": {:git, "https://github.com/shun159/eovsdb.git", "1ff1572708d72fd25631c681f2102407903252a3", [branch: "master"]},
"erlang_gobgp": {:git, "https://github.com/vasu-dasari/erlang-gobgp.git", "126bf98608a7f70ba78a81573b6861f95e8a2348", [branch: "master"]},
"erlware_commons": {:hex, :erlware_commons, "1.1.0", "f69f3d96044c2a9e735ccd76f469fec5fc851797e5fe23115698b4edc072191b", [:rebar3], [{:cf, "~>0.3", [hex: :cf, repo: "hexpm", optional: false]}], "hexpm"},
"erlydtl": {:git, "https://github.com/erlydtl/erlydtl.git", "032746b8068f367eb63923cb6f8b2095065015b9", []},
"eunit_formatters": {:hex, :eunit_formatters, "0.5.0", "6a9133943d36a465d804c1c5b6e6839030434b8879c5600d7ddb5b3bad4ccb59", [:rebar3], [], "hexpm"},
"ffi": {:git, "https://github.com/joshnuss/elixir-ffi.git", "b93183f27bd5d2cd6ce4c2c282801d4176e9462f", []},
"getopt": {:hex, :getopt, "1.0.1", "c73a9fa687b217f2ff79f68a3b637711bb1936e712b521d8ce466b29cbf7808a", [:rebar3], [], "hexpm"},
"gobgp": {:git, "https://github.com/vasu-dasari/erlang-gobgp.git", "126bf98608a7f70ba78a81573b6861f95e8a2348", [branch: "master"]},
"goldrush": {:git, "git://github.com/DeadZen/goldrush.git", "212299233c7e7eb63a97be2777e1c05ebaa58dbe", [tag: "0.1.8"]},
"gpb": {:hex, :gpb, "4.4.0", "cfd81b167f804b5a3720d7867530f6700e54644284431e4e14e032139c205251", [:make, :rebar], [], "hexpm"},
"grpc": {:git, "https://github.com/tony612/grpc-elixir.git", "c0eaa61d789f5c5b9e3c2f4c213944bebaf2c72c", []},
"grpc_client": {:git, "https://github.com/vasu-dasari/grpc_client.git", "930384100ddff5fb05ffb058f11b33df878c304f", [tag: "master"]},
"grpc_lib": {:git, "https://github.com/Bluehouse-Technology/grpc_lib", "a77686b55b60b052d6c7cd927d04dde429bbdabf", [branch: "master"]},
"gun": {:hex, :gun, "1.3.0", "18e5d269649c987af95aec309f68a27ffc3930531dd227a6eaa0884d6684286e", [:rebar3], [{:cowlib, "~> 2.6.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm"},
"jsone": {:git, "https://github.com/sile/jsone.git", "b23d312a5ed051ea7ad0989a9f2cb1a9c3f9a502", [tag: "1.4.6"]},
"lager": {:git, "https://github.com/basho/lager.git", "8187757388c9adc915379caaab36a2f2ca26e944", [tag: "3.2.1"]},
"nifty": {:git, "https://github.com/parapluu/nifty.git", "1534f6877d694db87e3c4a5c3cd46ee62a393245", []},
"proper": {:git, "https://github.com/proper-testing/proper.git", "16f9f7cb181f41ffb882c4a31052275dfad16ee1", [branch: "master"]},
"protobuf": {:hex, :protobuf, "0.5.4", "2e1b8eec211aff034ad8a14e3674220b0158bfb9a3c7128ac9d2a1ed1b3724d3", [:mix], [], "hexpm"},
"providers": {:hex, :providers, "1.7.0", "bbf730563914328ec2511d205e6477a94831db7297de313b3872a2b26c562eab", [:rebar3], [{:getopt, "1.0.1", [hex: :getopt, repo: "hexpm", optional: false]}], "hexpm"},
"ranch": {:hex, :ranch, "1.6.2", "6db93c78f411ee033dbb18ba8234c5574883acb9a75af0fb90a9b82ea46afa00", [:rebar3], [], "hexpm"},
"rebar": {:git, "https://github.com/erlang/rebar3.git", "33eb505573170ff8bf77d6b4758c88a75bf772d8", [tag: "3.5.3"]},
"rebar3": {:git, "https://github.com/erlang/rebar3.git", "33eb505573170ff8bf77d6b4758c88a75bf772d8", [tag: "3.5.3"]},
"relx": {:hex, :relx, "3.24.4", "2132f0abfa93db3177e66768db5a3d4141d4683bb4864b9dd4452ee7123ded07", [:rebar3], [{:bbmustache, "1.0.4", [hex: :bbmustache, repo: "hexpm", optional: false]}, {:cf, "0.2.2", [hex: :cf, repo: "hexpm", optional: false]}, {:erlware_commons, "1.0.5", [hex: :erlware_commons, repo: "hexpm", optional: false]}, {:getopt, "1.0.1", [hex: :getopt, repo: "hexpm", optional: false]}, {:providers, "1.7.0", [hex: :providers, repo: "hexpm", optional: false]}], "hexpm"},
"rustler": {:git, "https://github.com/hansihe/rustler.git", "d44bdbca496c761af7201ebad61a188092712ab1", [sparse: "rustler_mix"]},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.3", "6c49665d4326e26cd4a5b7bd54aa442b33dadfb7c5d59a0d0cd0bf5534bbfbd7", [:make, :mix, :rebar3], [], "hexpm"},
"sync": {:git, "https://github.com/rustyio/sync.git", "9b207f7396e8c037c66db1b3ca8f7b0338586397", [branch: "master"]},
"uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]},
}

View file

@ -0,0 +1,2 @@
target
Cargo.lock

View file

@ -0,0 +1,17 @@
[package]
name = "gobgp"
version = "0.1.0"
authors = ["HansiHE <hansihe@hansihe.com>"]
[lib]
name = "gobgp"
path = "src/lib.rs"
crate-type = ["dylib"]
[package.metadata.release]
[dependencies]
rustler = { git = "https://github.com/hansihe/rustler", branch = "remove_nif_from_types"}
rustler_codegen = { git = "https://github.com/hansihe/rustler", branch = "remove_nif_from_types"}
bufstream = "0.1.2"
lazy_static = "1.0.0"

View file

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rustc-link-search=native=../../vendor/libgobgp.so");
}

View file

@ -0,0 +1,40 @@
/* automatically generated by rust-bindgen */
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex<T> {
pub re: T,
pub im: T,
}
pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct max_align_t {
pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
pub __bindgen_padding_0: u64,
pub __clang_max_align_nonce2: f64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _GoString_ {
pub p: *const ::std::os::raw::c_char,
pub n: isize,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct buf {
pub value: *mut ::std::os::raw::c_char,
pub len: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct path_t {
pub nlri: buf,
pub path_attributes: *mut *mut buf,
pub path_attributes_len: ::std::os::raw::c_int,
pub path_attributes_cap: ::std::os::raw::c_int,
}

View file

@ -0,0 +1,27 @@
#![allow(bad_style, missing_copy_implementations, improper_ctypes)]
pub mod gobgp_utils;
#[macro_use] extern crate rustler;
#[macro_use] extern crate lazy_static;
use rustler::{Env, Term, NifResult, Encoder};
mod atoms {
rustler_atoms! {
atom ok;
}
}
rustler_export_nifs!(
"Elixir.EvpnRouter.GoBGP.NativeUtils",
[("get_route_family", 2, get_route_family)],
None
);
fn get_route_family<'a>(env: Env<'a>, args: &[Term<'a>]) -> NifResult<Term<'a>> {
let num1: i64 = args[0].decode()?;
let num2: i64 = args[1].decode()?;
Ok((atoms::ok(), num1 + num2).encode(env))
}