Skip to content

Commit e3489ba

Browse files
committed
update docs
1 parent c881b29 commit e3489ba

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

docs/pages/kotlinx-rpc/topics/configuration.topic

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
1010
title="Configuration" id="configuration">
11-
<p><code>RPCConfig</code> is a class used to configure <code>KRPCClient</code> and <code>KRPCServer</code>
12-
(not to be confused with <code>RPCClient</code> and <code>RPCServer</code>).
13-
It has two children: <code>RPCConfig.Client</code> and <code>RPCConfig.Server</code>.
11+
<p><code>KrpcConfig</code> is a class used to configure <code>KrpcClient</code> and <code>KrpcServer</code>
12+
(not to be confused with <code>KrpcClient</code> and <code>KrpcServer</code>).
13+
It has two children: <code>KrpcConfig.Client</code> and <code>KrpcConfig.Server</code>.
1414
<code>Client</code> and <code>Server</code> may have shared properties as well as distinct ones.
1515
To create instances of these configurations, DSL builders are provided
16-
(<code>RPCConfigBuilder.Client</code> class with <code>rpcClientConfig</code> function
17-
and <code>RPCConfigBuilder.Server</code> class with <code>rpcServerConfig</code> function respectively):
16+
(<code>KrpcConfigBuilder.Client</code> class with <code>rpcClientConfig</code> function
17+
and <code>KrpcConfigBuilder.Server</code> class with <code>rpcServerConfig</code> function respectively):
1818
</p>
1919

2020
<code-block lang="kotlin">
21-
val config: RPCConfig.Client = rpcClientConfig { // same for RPCConfig.Server with rpcServerConfig
21+
val config: KrpcConfig.Client = rpcClientConfig { // same for KrpcConfig.Server with rpcServerConfig
2222
waitForServices = true // default parameter
2323
}
2424
</code-block>
@@ -81,7 +81,7 @@
8181
But instances of these flows when deserialized should be created somehow,
8282
so to overcome this - configuration parameter is created.
8383
Configuration builder allows defining these parameters
84-
and produces a builder function that is then placed into the <code>RPCConfig</code>.</p>
84+
and produces a builder function that is then placed into the <code>KrpcConfig</code>.</p>
8585
</chapter>
8686
<chapter id="waitforservices-dsl">
8787
<title>
@@ -90,10 +90,10 @@
9090
<p><code>waitForServices</code> parameter is available for both client and server.
9191
It specifies the behavior for an endpoint in situations
9292
when the message for a service is received,
93-
but the service is not present in <code>RPCClient</code> or <code>RPCServer</code>.
93+
but the service is not present in <code>KrpcClient</code> or <code>KrpcServer</code>.
9494
If set to <code>true</code>, the message will be stored in memory,
9595
otherwise, the error will be sent to a peer endpoint,
9696
saying that the message was not handled.
9797
Default value is <code>true</code>.</p>
9898
</chapter>
99-
</topic>
99+
</topic>

docs/pages/kotlinx-rpc/topics/features.topic

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<control>fields</control>
146146
(<code>replayCache</code> for <code>SharedFlow</code> and <code>StateFlow</code>, and <code>value</code>
147147
for <code>StateFlow</code>)
148-
you will get a <code>UninitializedRPCFieldException</code>.
148+
you will get a <code>UninitializedRpcFieldException</code>.
149149
If you call a suspend <code>collect</code> method on them,
150150
execution will suspend until the state is
151151
<emphasis>initialized</emphasis>
@@ -164,7 +164,7 @@
164164
// ### Somewhere in client code ###
165165
val myService: MyService = rpcClient.withService&lt;MyService&gt;()
166166

167-
val value = myService.flow.value // throws UninitializedRPCFieldException
167+
val value = myService.flow.value // throws UninitializedRpcFieldException
168168
val value = myService.awaitFieldInitialization { flow }.value // OK
169169
// or
170170
val value = myService.awaitFieldInitialization().flow.value // OK
@@ -173,7 +173,7 @@
173173
</code-block>
174174
<p>Secondly, we provide you with an instrument to make initialization faster.
175175
By default, all fields are lazy.
176-
By adding <code>@RPCEagerField</code> annotation, you can change this behavior,
176+
By adding <code>@RpcEagerField</code> annotation, you can change this behavior,
177177
so that fields will be initialized when the service in created
178178
(when <code>withService</code> method is called):</p>
179179

@@ -182,7 +182,7 @@
182182
interface MyService : RemoteService {
183183
val lazyFlow: Flow&lt;Int&gt; // initialized on first access
184184

185-
@RPCEagerField
185+
@RpcEagerField
186186
val eagerFlow: Flow&lt;Int&gt; // initialized on service creation
187187
}
188188
</code-block>

docs/pages/kotlinx-rpc/topics/rpc-clients.topic

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,61 +23,61 @@
2323
In this case, you can use the generated code.
2424
</tip>
2525
<p>
26-
To be able to obtain an instance of your service, you need to have an <code>RPCClient</code>.
26+
To be able to obtain an instance of your service, you need to have an <code>RpcClient</code>.
2727
You can call the <code>withService()</code> method on your client:
2828
</p>
2929
<code-block lang="kotlin">
30-
val rpcClient: RPCClient
30+
val rpcClient: RpcClient
3131

3232
val myService: MyService = rpcClient.withService&lt;MyService&gt;()
3333
</code-block>
3434
<p>
3535
Now you have your client instance that is able to send RPC requests to your server.
36-
<code>RPCClient</code> can have multiple services that communicate through it.
37-
Conceptually, <code>RPCClient</code> is an abstraction of a client,
36+
<code>RpcClient</code> can have multiple services that communicate through it.
37+
Conceptually, <code>RpcClient</code> is an abstraction of a client,
3838
that is able to convent service requests
39-
(represented by <code>RPCCall</code> and <code>RPCField</code> classes)
39+
(represented by the <code>RpcCall</code> class)
4040
into actual network requests.
4141
</p>
4242
<p>
43-
You can provide your own implementations of the <code>RPCClient</code>.
43+
You can provide your own implementations of the <code>RpcClient</code>.
4444
But <code>kotlinx.rpc</code> already provides one out-of-the-box solution that uses
4545
in-house RPC protocol (called kRPC), and we are working on supporting more protocols
4646
(with priority on gRPC).
4747
</p>
4848

49-
<chapter title="KRPCClientRPCClient for kRPC Protocol" id="krpcclient-rpcclient-for-krpc-protocol">
50-
<p><code>KRPCClient</code> is an abstract class that implements <code>RPCClient</code> and kRPC protocol
49+
<chapter title="KrpcClientRpcClient for kRPC Protocol" id="krpcclient-rpcclient-for-krpc-protocol">
50+
<p><code>KrpcClient</code> is an abstract class that implements <code>RpcClient</code> and kRPC protocol
5151
logic.
5252
The only thing required to be implemented is the transporting of the raw data.
53-
Abstract transport is represented by <code>RPCTransport</code> interface.</p>
54-
<p>To implement your own <code>RPCTransport</code>
53+
Abstract transport is represented by <code>KrpcTransport</code> interface.</p>
54+
<p>To implement your own <code>KrpcTransport</code>
5555
you need to be able to transfer strings and/or raw bytes (Kotlin's <code>ByteArray</code>).
5656
Additionally, the library will provide you with <a href="transport.topic">integrations with different
5757
libraries</a> that are used to work with the network.
5858
</p>
5959
<p>See below an example usage of kRPC with a custom transport:</p>
6060

6161
<code-block lang="kotlin">
62-
class MySimpleRPCTransport : RPCTransport {
63-
val outChannel = Channel&lt;RPCTransportMessage&gt;()
64-
val inChannel = Channel&lt;RPCTransportMessage&gt;()
62+
class MySimpleRpcTransport : KrpcTransport {
63+
val outChannel = Channel&lt;KrpcTransportMessage&gt;()
64+
val inChannel = Channel&lt;KrpcTransportMessage&gt;()
6565

6666
override val coroutineContext: CoroutineContext = Job()
6767

68-
override suspend fun send(message: RPCTransportMessage) {
68+
override suspend fun send(message: KrpcTransportMessage) {
6969
outChannel.send(message)
7070
}
7171

72-
override suspend fun receive(): RPCTransportMessage {
72+
override suspend fun receive(): KrpcTransportMessage {
7373
return inChannel.receive()
7474
}
7575
}
7676

77-
class MySimpleRPCClient : KRPCClient(rpcClientConfig(), MySimpleRPCTransport())
77+
class MySimpleRpcClient : KrpcClient(rpcClientConfig(), MySimpleRpcTransport())
7878

79-
val client = MySimpleRPCClient()
79+
val client = MySimpleRpcClient()
8080
val service: MyService = client.withService&lt;MyService&gt;()
8181
</code-block>
8282
</chapter>
83-
</topic>
83+
</topic>

docs/pages/kotlinx-rpc/topics/rpc-servers.topic

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
1010
title="RPC Servers" id="rpc-servers">
11-
<p><code>RPCServer</code> interface represents an RPC server,
11+
<p><code>RpcServer</code> interface represents an RPC server,
1212
that accepts RPC messages and may contain multiple services to route to.
13-
<code>RPCServer</code> uses data from incoming RPC messages
13+
<code>RpcServer</code> uses data from incoming RPC messages
1414
and routes it to the designated service and sends service's response back to the corresponding client.
1515
</p>
16-
<p>You can provide your own <code>RPCServer</code> implementation
16+
<p>You can provide your own <code>RpcServer</code> implementation
1717
or use the one provided out of the box.
1818
Note that client and server must use the same RPC protocol to communicate.</p>
1919
<p>Use <code>registerService</code> function to add your own factory for implemented RPC services.
@@ -23,7 +23,7 @@
2323
<p>Example usage:</p>
2424

2525
<code-block lang="kotlin">
26-
val server: RPCServer
26+
val server: RpcServer
2727

2828
server.registerService&lt;MyService&gt; { ctx: CoroutineContext -&gt; MyServiceImpl(ctx) }
2929
</code-block>
@@ -36,23 +36,23 @@
3636
server.registerService&lt;MyServiceImpl&gt; { ctx: CoroutineContext -&gt; MyServiceImpl(ctx) }
3737
</code-block>
3838

39-
<chapter title="KRPCServerRPCServer for kRPC Protocol" id="krpcserver-rpcserver-for-krpc-protocol">
40-
<p><code>KRPCServer</code> abstract class implements <code>RPCServer</code>
39+
<chapter title="KrpcServerRpcServer for kRPC Protocol" id="krpcserver-rpcserver-for-krpc-protocol">
40+
<p><code>KrpcServer</code> abstract class implements <code>RpcServer</code>
4141
and all the logic for processing RPC messages
42-
and again leaves <code>RPCTransport</code> methods for the specific implementations
42+
and again leaves <code>RpcTransport</code> methods for the specific implementations
4343
(see <a href="transport.topic">transports</a>).</p>
4444
<p>Example usage with custom transport:</p>
4545

4646
<code-block lang="kotlin">
47-
// same MySimpleRPCTransport as in the client example above
48-
class MySimpleRPCServer : KRPCServer(rpcServerConfig(), MySimpleRPCTransport())
47+
// same MySimpleRpcTransport as in the client example above
48+
class MySimpleRpcServer : KrpcServer(rpcServerConfig(), MySimpleRpcTransport())
4949

50-
val server = MySimpleRPCServer()
50+
val server = MySimpleRpcServer()
5151
server.registerService&lt;MyService&gt; { ctx -&gt; MyServiceImpl(ctx) }
5252
</code-block>
5353
<p>Note that here we pass explicit <code>MyService</code> type parameter to the <code>registerService</code>
5454
method.
5555
You must explicitly specify the type of the service interface here,
5656
otherwise the server service will not be found.</p>
5757
</chapter>
58-
</topic>
58+
</topic>

docs/pages/kotlinx-rpc/topics/transport.topic

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<p>Transport layer exists to abstract from the RPC requests logic and focus on delivering and receiving
1313
encoded RPC messages in kRPC Protocol.
14-
This layer is represented by <code>RPCTransport</code> interface.
14+
This layer is represented by <code>KrpcTransport</code> interface.
1515
It supports two message formats — string and binary,
1616
and depending on which <a href="configuration.topic" anchor="serialization-dsl">serialization</a> format you choose,
1717
one or the other will be used.</p>
@@ -22,21 +22,21 @@
2222
protocol.
2323
This includes both server and client APIs.
2424
Under the hood, the library uses <a href="https://ktor.io/docs/websocket.html">WebSocket</a> plugin
25-
to create a <code>RPCTransport</code> and send and receive messages through it.</p>
25+
to create a <code>KrpcTransport</code> and send and receive messages through it.</p>
2626
<chapter title="Client" id="client">
2727
<p><code>kotlinx.rpc</code> provides a way to plug-in into existing Ktor clients with your RPC services.
2828
To do that, the following DSL can be used:</p>
2929

3030
<code-block lang="kotlin">
3131
val ktorClient = HttpClient {
32-
installRPC { // this: RPCConfigBuilder.Client
32+
installKrpc { // this: KrpcConfigBuilder.Client
3333
waitForServices = true
3434
}
3535
}
3636

37-
val rpcClient: KtorRPCClient =
37+
val rpcClient: KtorKrpcClient =
3838
ktorClient.rpc(&quot;ws://localhost:4242/services&quot;) { // this: HttpRequestBuilder
39-
rpcConfig { // this: RPCConfigBuilder.Client
39+
rpcConfig { // this: KrpcConfigBuilder.Client
4040
waitForServices = false
4141
}
4242
}
@@ -47,7 +47,7 @@
4747
// create RPC service
4848
val myService: MyService = rpcClient.withService&lt;MyService&gt;()
4949
</code-block>
50-
<p>Note that in this example, only the latter defined <code>RPCConfig</code> will be used.</p>
50+
<p>Note that in this example, only the latter defined <code>KrpcConfig</code> will be used.</p>
5151
</chapter>
5252
<chapter title="Server" id="server">
5353
<p><code>kotlinx.rpc</code> provides a way to plug-in into existing server routing with your RPC
@@ -56,13 +56,13 @@
5656

5757
<code-block lang="kotlin">
5858
fun Application.module() {
59-
install(RPC) { // this: RPCConfigBuilder.Server
59+
install(Krpc) { // this: KrpcConfigBuilder.Server
6060
waitForServices = true
6161
}
6262

6363
routing {
64-
rpc(&quot;/services&quot;) { // this RPCRoute, inherits WebSocketSession
65-
rpcConfig { // this: RPCConfigBuilder.Server
64+
rpc(&quot;/services&quot;) { // this KrpcRoute, inherits WebSocketSession
65+
rpcConfig { // this: KrpcConfigBuilder.Server
6666
waitForServices = false
6767
}
6868

@@ -94,7 +94,7 @@
9494
// ### CLIENT CODE ###
9595

9696
val client = HttpClient {
97-
installRPC {
97+
installKrpc {
9898
serialization {
9999
json()
100100
}
@@ -124,7 +124,7 @@
124124

125125
fun main() {
126126
embeddedServer(Netty, port = 8080) {
127-
install(RPC) {
127+
install(Krpc) {
128128
serialization {
129129
json()
130130
}

0 commit comments

Comments
 (0)