Skip to content
Permalink
Browse files
add english version for language section (3.0) (#994)
Co-authored-by: Yunkun Huang <htyhkn@gmail.com>
  • Loading branch information
htynkn and Yunkun Huang committed Nov 25, 2021
1 parent 87872a1 commit 85531dafa4d563f5ee696e6e14a81bc791de3fab
Showing 10 changed files with 397 additions and 0 deletions.
@@ -7,3 +7,4 @@ package-lock.json
.idea/

.DS_Store
/.hugo_build.lock
@@ -0,0 +1,8 @@

---
type: docs
title: "Multi-language implementation"
linkTitle: "multi-language"
weight: 60
description: "Dubbo support multi-language implementation, please learn about the special usage of each language"
---
@@ -0,0 +1,9 @@

---
type: docs
title: "Erlang"
linkTitle: "Erlang"
weight: 200
description: "Erlang support"
---

@@ -0,0 +1,71 @@
---
type: docs
title: "Quick start "
linkTitle: "Quick start"
weight: 1
description: "Erlang Quick start"
---

It is recommended to use java to define the interface jar first, and use the [erlanalysis](https://github.com/apache/dubbo-erlang/tree/master/tools/erlanalysis) tool to parse the java interface to Erlang lib


## Import dependent libraries

### Use the Rebar compilation tool.

Add dubblerl to rebar.config to your project

```erlang
{deps, [
{dubboerl, {git, "https://github.com/apache/dubbo-erlang.git", {branch, "master"}}}
]}.
```

### Use erlang.mk compilation tool

`in progress...`

## Import interface library
Suppose the interface lib you exported is called dubbo_service.
* If you didn't upload your lib to your git repository, It is recommended that you copy the `dubbo_service` lib
into the project's `apps` directory.
* If it is uploaded to your git repository, you can import like this:
```erlang
{deps, [
{dubboerl, {git, "https://github.com/apache/dubbo-erlang.git", {branch, "master"}}},
{dubbo_service,{git,"${INTERFACE_LIB_URL}",{branch,"master"}}} %% replace ${INTERFACE_LIB_URL} with your lib git repos url
]}.
```

## Consumer configuration
Please reference [Reference Config](./reference.md)

## Init dubbolib in your project
It is need you
```erlang
dubboerl:init().
```

## How to call?

### Synchronous call

```erlang
Request = #userInfoRequest{requestId = 123, username = "testname"},
{ok,RequestRef,Response,RpcContent} = userOperator:queryUserInfo(Request,#{sync=> true}).
```
If it occur error, is reponse `{error,Reason}`.

### Asynchronous call

Default is Async call.
```erlang
Request = #userInfoRequest{requestId = 123, username = "testname"},
{ok,RequestRef} = userOperator:queryUserInfo(Request).
%% you can receive the message after.
handle_cast({msg_back,RequestRef,Response,RpcContent},State).
```

## Example
Refer to [dubboerl_demo](https://github.com/apache/dubbo-erlang/tree/master/samples)
@@ -0,0 +1,24 @@
---
type: docs
title: "Consumer configuration"
linkTitle: "Consumer configuration"
weight: 2
description: "Configure consumers in erlang"
---

## Basic configuration

Consumers need to add configuration items to `sys.config` file `dubboerl` filed.

```erlang
{dubboerl,[
%% other config ...
{consumer,[
{<<"interface fullname">>,[Option]},
%% eg:
{<<"org.apache.dubbo.erlang.sample.service.facade.UserOperator">>,[]},
]}
]}
```

Option is to be added.
@@ -0,0 +1,26 @@
---
type: docs
title: "Serialized configuration items"
linkTitle: "Serialized configuration items"
weight: 4
description: "Configure the serialization method in erlang"
---

The library currently only implements the `dubbo://` communication protocol.

It supports `hessian` and `json` as serialization method.

## Configuration example

Provider configuration items to add to the `sys.config` file `dubboerl` field.

```erlang
{dubboerl,[
%% other config ...
{protocol,hessian}
]}
```

| ConfigName | Type | DefaultValue | Remarks |
| --- | --- | --- | --- |
| protocol | atom() | hessian | hessian,json |
@@ -0,0 +1,30 @@
---
type: docs
title: "Provider configuration"
linkTitle: "Provider configuration"
weight: 3
description: "Configure service provider in erlang"
---

## basic configuration

Provider configuration items to add to the `sys.config` file `dubboerl` field

```erlang
{dubboerl,[
%% other config ...
{provider,[
{module_implements,interface_module,interface_fullname,[Options]},
%% eg:
{userOperator_impl,userOperator,<<"org.apache.dubbo.erlang.sample.service.facade.UserOperator">>,[Option]}
]}
]}
```

| ConfigName | Type | DefaultValue | Remarks |
| --- | --- | --- | --- |
| module_implements | atom() | - | The service implements module name|
| interface_module | atom() | - | Interface module name is transfer form java jar |
| interface_fullname | binary() | - | Interface full name is the java class name |

Option is to be added.
@@ -0,0 +1,9 @@

---
type: docs
title: "golang"
linkTitle: "golang"
weight: 200
description: "golang support"
---

@@ -0,0 +1,7 @@
---
type: docs
title: "Go language definition service"
linkTitle: "Go language definition service"
weight: 10
description: ""
---

0 comments on commit 85531da

Please sign in to comment.