Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
a984a0fb
Commit
a984a0fb
authored
Dec 11, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document RPC.
parent
3c7efbb4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
29 deletions
+49
-29
header.html
doc/_includes/header.html
+2
-1
capnp_lexer.py
doc/_plugins/capnp_lexer.py
+1
-1
cxx.md
doc/cxx.md
+11
-4
cxxrpc.md
doc/cxxrpc.md
+0
-0
time-travel.png
doc/images/time-travel.png
+0
-0
index.md
doc/index.md
+5
-0
language.md
doc/language.md
+30
-23
rpc.md
doc/rpc.md
+0
-0
No files found.
doc/_includes/header.html
View file @
a984a0fb
...
...
@@ -39,7 +39,8 @@
<li><a
href=
"{{ site.baseurl }}encoding.html"
>
Encoding
</a></li>
<li><a
href=
"{{ site.baseurl }}rpc.html"
>
RPC Protocol
</a></li>
<li><a
href=
"{{ site.baseurl }}capnp-tool.html"
>
The
<code>
capnp
</code>
Tool
</a></li>
<li><a
href=
"{{ site.baseurl }}cxx.html"
>
C++ Runtime
</a></li>
<li><a
href=
"{{ site.baseurl }}cxx.html"
>
C++ Serialization
</a></li>
<li><a
href=
"{{ site.baseurl }}cxxrpc.html"
>
C++ RPC
</a></li>
<li><a
href=
"{{ site.baseurl }}otherlang.html"
>
Other Languages
</a></li>
<li><a
href=
"{{ site.baseurl }}roadmap.html"
>
Road Map
</a></li>
</ul>
...
...
doc/_plugins/capnp_lexer.py
View file @
a984a0fb
...
...
@@ -15,7 +15,7 @@ class CapnpLexer(RegexLexer):
(
r'='
,
Literal
,
'expression'
),
(
r':'
,
Name
.
Class
,
'type'
),
(
r'\$'
,
Name
.
Attribute
,
'annotation'
),
(
r'(struct|enum|interface|union|import|using|const|annotation|in|of|on|as|with|from|fixed)\b'
,
(
r'(struct|enum|interface|union|import|using|const|annotation|
extends|
in|of|on|as|with|from|fixed)\b'
,
Token
.
Keyword
),
(
r'[a-zA-Z0-9_.]+'
,
Token
.
Name
),
(
r'[^#@=:$a-zA-Z0-9_]+'
,
Text
),
...
...
doc/cxx.md
View file @
a984a0fb
...
...
@@ -3,10 +3,11 @@ layout: page
title
:
C++ Runtime
---
# C++
Runtime
# C++
Serialization
The Cap'n Proto C++ runtime implementation provides an easy-to-use interface for manipulating
messages backed by fast pointer arithmetic.
messages backed by fast pointer arithmetic. This page discusses the serialization layer of
the runtime; see
[
C++ RPC
](
cxxrpc.html
)
for information about the RPC layer.
## Example Usage
...
...
@@ -173,7 +174,13 @@ To generate C++ code from your `.capnp` [interface definition](language.html), r
This will create
`myproto.capnp.h`
and
`myproto.capnp.c++`
in the same directory as
`myproto.capnp`
.
To use this code in your app, you must link against both
`libcapnp`
and
`libkj`
.
To use this code in your app, you must link against both
`libcapnp`
and
`libkj`
. If you use
`pkg-config`
, Cap'n Proto provides the
`capnp`
module to simplify discovery of compiler and linker
flags.
If you use
[
RPC
](
cxxrpc.html
)
(
i.e.,
your schema defines
[
interfaces
](
language.html#interfaces
)
),
then you will additionally nead to link against
`libcapnp-rpc`
and
`libkj-async`
, or use the
`capnp-rpc`
`pkg-config`
module.
### Setting a Namespace
...
...
@@ -362,7 +369,7 @@ implicitly convertible in this way. Unfortunately, this trick doesn't work on G
### Interfaces
Interfaces (RPC) are not yet implemented at this time.
[
Interfaces (RPC) have their own page.
](
cxxrpc.html
)
### Constants
...
...
doc/cxxrpc.md
0 → 100644
View file @
a984a0fb
This diff is collapsed.
Click to expand it.
doc/images/time-travel.png
0 → 100644
View file @
a984a0fb
29 KB
doc/index.md
View file @
a984a0fb
...
...
@@ -67,6 +67,11 @@ Glad you asked!
order of magnitude or more. In fact, usually it's no more than some inline accessor methods!
*
**Tiny runtime library:**
Due to the simplicity of the Cap'n Proto format, the runtime library
can be much smaller.
*
**Time-traveling RPC:**
Cap'n Proto features an RPC system implements
[
time travel
](
rpc.html
)
such that call results are returned to the client before the request even arrives at the server!
<a
href=
"rpc.html"
><img
src=
'images/time-travel.png'
style=
'max-width:639px'
></a>
**_Why do you pick on Protocol Buffers so much?_**
...
...
doc/language.md
View file @
a984a0fb
...
...
@@ -13,8 +13,7 @@ manipulate that message type in your desired language.
For example:
{% highlight capnp %}
# unique file ID, generated by `capnp id`
@0xdbb9ad1f14bf0b36;
@0xdbb9ad1f14bf0b36; # unique file ID, generated by
`capnp id`
struct Person {
name @0 :Text;
...
...
@@ -304,38 +303,46 @@ be considered numeric.
### Interfaces
An interface has a collection of methods, each of which takes some parameters and returns a
result. Like struct fields, methods are numbered.
An interface has a collection of methods, each of which takes some parameters and return some
results. Like struct fields, methods are numbered. Interfaces support inheritance, including
multiple inheritance.
{% highlight capnp %}
interface Directory {
list @0 () :List(FileInfo);
create @1 (name :Text) :FileInfo;
open @2 (name :Text) :FileInfo;
delete @3 (name :Text) :Void;
link @4 (name :Text, file :File) :Void;
interface Node {
isDirectory @0 () -> (result :Bool);
}
struct FileInfo {
name @0 :Text;
size @1 :UInt64;
file @2 :File; # A pointer to a File.
interface Directory extends(Node) {
list @0 () -> (list: List(Entry));
struct Entry {
name @0 :Text;
node @1 :Node;
}
create @1 (name :Text) -> (file :File);
mkdir @2 (name :Text) -> (directory :Directory)
open @3 (name :Text) -> (node :Node);
delete @4 (name :Text);
link @5 (name :Text, node :Node);
}
interface File {
read @0 (startAt :UInt64 = 0, amount :UInt64 = 0xffffffffffffffff) :Data;
interface File extends(Node) {
size @0 () -> (size: UInt64);
read @1 (startAt :UInt64 = 0, amount :UInt64 = 0xffffffffffffffff)
-> (data: Data);
# Default params = read entire file.
write @
1 (startAt :UInt64, data :Data) :Void
;
truncate @
2 (size :UInt64) :Void
;
write @
2 (startAt :UInt64, data :Data)
;
truncate @
3 (size :UInt64)
;
}
{% endhighlight %}
Notice something interesting here:
`FileInfo`
is a struct, but it contains a
`File`
, which is an
interface. Structs (and primitive types) are passed over RPC by value, but interfaces are passed by
reference. So when
`Directory.open`
is called remotely, the content of a
`FileInfo`
(including
values for
`name`
and
`size`
) is transmitted back, but for the
`file`
field, only the address of
some remote
`File`
object is sent.
Notice something interesting here:
`Node`
,
`Directory`
, and
`File`
are interfaces, but several
methods take these types as parameters or return them as results.
`Directory.Entry`
is a struct,
but it contains a
`Node`
, which is an interface. Structs (and primitive types) are passed over RPC
by value, but interfaces are passed by reference. So when
`Directory.list`
is called remotely, the
content of a
`List(Entry)`
(including the text of each
`name`
) is transmitted back, but for the
`node`
field, only a reference to some remote
`Node`
object is sent.
When an address of an object is transmitted, the RPC system automatically manages making sure that
the recipient gets permission to call the addressed object -- because if the recipient wasn't
...
...
doc/rpc.md
View file @
a984a0fb
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment