Skip to content

Commit 3c39e85

Browse files
committed
Update readme
Editorial review (structure, style, language, typos)
1 parent 94b959d commit 3c39e85

File tree

1 file changed

+60
-42
lines changed

1 file changed

+60
-42
lines changed

README.md

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,95 @@
1-
You could get [1.6.9](https://github.com/tarantool/tarantool-java/tree/connector-1.6.9)
1+
<a href="http://tarantool.org">
2+
<img src="https://avatars2.githubusercontent.com/u/2344919?v=2&s=250"
3+
align="right">
4+
</a>
25

3-
# Java Connector for Tarantool 1.7.4
6+
# Java connector for Tarantool 1.7.4+
47

58
[![Join the chat at https://gitter.im/tarantool/tarantool-java](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tarantool/tarantool-java?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
69

7-
## Problems & Questions
8-
http://stackoverflow.com/questions/ask/advice with tags `tarantool` and `java`.
10+
To get the Java connector for Tarantool 1.6.9, visit
11+
[this GitHub page](https://github.com/tarantool/tarantool-java/tree/connector-1.6.9).
912

10-
## Note
11-
Tarantool client is not supports name resolving for fields, indexes, space etc. I highly recommend to use server side lua to
12-
operate with named items. For example you could create dao object with simple CRUD functions.
13-
If you still need client name resolving for some reasons you could create function which will return required maps with name to id mappings.
13+
## Table of contents
14+
* [Getting started](#getting-started)
15+
* [Where to get help](#where-to-get-help)
1416

15-
## How to start
17+
## Getting started
18+
19+
1. Add a dependency to your `pom.xml` file.
1620

17-
First you should add dependency to your pom file
1821
```xml
1922
<dependency>
2023
<groupId>org.tarantool</groupId>
2124
<artifactId>connector</artifactId>
2225
<version>1.7.4</version>
2326
</dependency>
2427
```
25-
Second configure TarantoolClientConfig.
28+
29+
2. Configure `TarantoolClientConfig`.
2630

2731
```java
28-
TarantoolClientConfig config = new TarantoolClientConfig();
29-
config.username = "test";
30-
config.password = "test";
32+
TarantoolClientConfig config = new TarantoolClientConfig();
33+
config.username = "test";
34+
config.password = "test";
3135
```
3236

33-
Then implements your SocketChannelProvider. SocketChannelProvider should return connected SocketChannel.
34-
Here you also could implement some reconnect or fallback policy. Remember that TarantoolClient uses [fail fast
35-
policy](https://en.wikipedia.org/wiki/Fail-fast) when client is not connected.
36-
37+
3. Implement your `SocketChannelProvider`.
38+
It should return a connected `SocketChannel`.
3739

3840
```java
39-
SocketChannelProvider socketChannelProvider = new SocketChannelProvider() {
40-
@Override
41-
public SocketChannel get(int retryNumber, Throwable lastError) {
42-
if (lastError != null) {
43-
lastError.printStackTrace(System.out);
44-
}
45-
try {
46-
return SocketChannel.open(new InetSocketAddress("localhost", 3301));
47-
} catch (IOException e) {
48-
throw new IllegalStateException(e);
49-
}
50-
}
51-
};
41+
SocketChannelProvider socketChannelProvider = new SocketChannelProvider() {
42+
@Override
43+
public SocketChannel get(int retryNumber, Throwable lastError) {
44+
if (lastError != null) {
45+
lastError.printStackTrace(System.out);
46+
}
47+
try {
48+
return SocketChannel.open(new InetSocketAddress("localhost", 3301));
49+
} catch (IOException e) {
50+
throw new IllegalStateException(e);
51+
}
52+
}
53+
};
5254
```
5355

54-
Now you are ready to create client
56+
Here you could also implement some reconnection or fallback policy.
57+
Remember that `TarantoolClient` adopts a
58+
[fail-fast](https://en.wikipedia.org/wiki/Fail-fast) policy
59+
when a client is not connected.
60+
61+
4. Create a client.
62+
5563
```java
5664
TarantoolClient client = new TarantoolClientImpl(socketChannelProvider, config);
5765
```
5866

59-
TarantoolClient is thread safe and async so you should use one client inside whole application.
67+
> **Notes:**
68+
> * `TarantoolClient` is thread-safe and asynchronous, so you should use one
69+
> client inside the whole application.
70+
> * `TarantoolClient` does not support name resolution for fields, indexes,
71+
> spaces and so on. We highly recommend to use server-side Lua when working
72+
> with named items. For example, you could create a data access object (DAO)
73+
> with simple CRUD functions. If, for some reason, you do need client name
74+
> resolution, you could create a function that returns necessary name-to-ID
75+
> mappings.
6076
61-
TarantoolClient provides 3 interfaces to execute queries
77+
`TarantoolClient` provides three interfaces to execute queries:
6278

63-
* SyncOps returns operation result
64-
* AsyncOps returns operation result Future
65-
* FireAndForgetOps returns query ID
79+
* `SyncOps` - returns the operation result
80+
* `AsyncOps` - returns the operation result as a `Future`
81+
* `FireAndForgetOps` - returns the query ID
6682

83+
Feel free to override any method of `TarantoolClientImpl`. For example, to hook
84+
all the results, you could override this:
6785

68-
Feel free to override any method of TarantoolClientImpl. For example you
69-
could override
7086
```java
7187
protected void complete(long code, FutureImpl<List> q);
7288
```
73-
to hook all results.
74-
75-
7689

90+
## Where to get help
7791

92+
Got problems or questions? Post them on
93+
[Stack Overflow](http://stackoverflow.com/questions/ask/advice) with the
94+
`tarantool` and `java` tags, or use these tags to search the existing knowledge
95+
base for possible answers and solutions.

0 commit comments

Comments
 (0)