Skip to content

Commit 9360752

Browse files
author
Kutluhan Metin
authored
[CLC-215]: Serializer Generator Documentation (hazelcast#406)
1 parent 14c0c4e commit 9360752

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

docs/modules/ROOT/nav.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
** xref:clc-version.adoc[]
3434
** xref:clc-viridian.adoc[]
3535
** xref:clc-project.adoc[]
36+
** xref:clc-serializer-generator.adoc[]
3637
* xref:configuration-format.adoc[]
3738
* xref:environment-variables.adoc[]
3839
* xref:keyboard-shortcuts.adoc[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
= clc serializer generator (Beta)
2+
3+
Serializer commands are a group of serializer generator operations.
4+
5+
Check out the documentation for https://docs.hazelcast.com/hazelcast/latest/serialization/compact-serialization[Compact Serialization] for more information.
6+
7+
Usage:
8+
9+
[source,bash]
10+
----
11+
clc serializer [command] [flags]
12+
----
13+
14+
== Commands
15+
16+
* <<clc-serializer-generate, clc serializer generate>>
17+
18+
== clc serializer generate
19+
20+
Generates compact serialization code from the given schema for the target language. See https://docs.hazelcast.com/hazelcast/latest/serialization/compact-serialization#implementing-compactserializer[Compact Serialization] documentation for more information.
21+
22+
Usage:
23+
24+
[source, bash]
25+
----
26+
clc serializer generate [schema] [flags]
27+
----
28+
29+
Parameters:
30+
31+
[cols="1m,1a,2a,1a"]
32+
|===
33+
|Parameter|Required|Description|Default
34+
35+
|`output-dir`, `-o`
36+
|Optional
37+
|Output directory for the serialization files.
38+
|Current working directory.
39+
40+
|`language`, `-l`
41+
|Required
42+
|Programming language that the serializer created for.
43+
|
44+
|===
45+
46+
Example:
47+
48+
[source,bash]
49+
----
50+
clc serializer generate my-schema.yaml --language java --output-dir my-dir
51+
----
52+
53+
=== Schema Creation
54+
55+
A schema allows you to:
56+
57+
* describe the contents of a compact class using supported field types
58+
* import other schema
59+
* specify a namespaces for schema files and reference other namespaces
60+
* define cyclic references between classes
61+
* reference classes that are not present in the given schemas
62+
63+
A schema is written in YAML. Schema format is given below:
64+
65+
[source,yaml]
66+
----
67+
namespace: <namespace of the class>
68+
# note that other schema files can be imported with relative path to this yaml file
69+
imports:
70+
- someOtherSchema.yaml
71+
# All objects in this file will share the same namespace.
72+
classes:
73+
- name: <name of the class>
74+
fields:
75+
- name: <field name>
76+
type: <field type>
77+
external: bool # to mark external types (external to this yaml file)
78+
----
79+
80+
==== namespace
81+
82+
Used for logical grouping of classes. Typically, for every namespace, you will have a schema file. Namespace is optional. If not provided, the classes will be generated at global namespace (no namespace). The user should provide the language specific best practice when using the namespace. The tool will use the namespace while generating code if provided.
83+
84+
==== imports
85+
86+
Used to import other schema files. The type definitions in the imported yaml schemas can be used within this yaml file. Cyclic imports will be checked and handled properly. For this version of the tool, an import can only be a single file name and the tool will assume all yaml files imported will be in the same directory as the importing schema file.
87+
88+
==== classes
89+
90+
Used to define classes in the schema.
91+
92+
* name: Name of the class
93+
* fields: Field specification of the class
94+
** name: Name of the field
95+
** type: Type of the field. Normally you should refer to another class as namespace.classname. You can use a class without namespace when the class is defined in the same schema yaml file. type can be one of the following:
96+
*** `boolean`
97+
*** `boolean[]`
98+
*** `int8`
99+
*** `int8[]`
100+
*** `int16`
101+
*** `int16[]`
102+
*** `int32`
103+
*** `int32[]`
104+
*** `int64`
105+
*** `int64[]`
106+
*** `float32`
107+
*** `float32[]`
108+
*** `float64`
109+
*** `float64[]`
110+
*** `string`
111+
*** `string[]`
112+
*** `date`
113+
*** `date[]`
114+
*** `time`
115+
*** `time[]`
116+
*** `timestamp`
117+
*** `timestamp[]`
118+
*** `timestampWithTimezone`
119+
*** `timestampWithTimezone[]`
120+
*** `nullableBoolean`
121+
*** `nullableBoolean[]`
122+
*** `nullableInt8`
123+
*** `nullableInt8[]`
124+
*** `nullableInt16`
125+
*** `nullableInt16[]`
126+
*** `nullableInt32`
127+
*** `nullableInt32[]`
128+
*** `nullableInt64`
129+
*** `nullableInt64[]`
130+
*** `nullableFloat32`
131+
*** `nullableFloat32[]`
132+
*** `nullableFloat64`
133+
*** `nullableFloat64[]`
134+
*** `<OtherCompactClass[]>`
135+
** external:
136+
*** Used to mark if the type is external. If a field is external, the tool will not check if it is imported and available. External types are managed by the user and not generated by the tool.
137+
*** The serializer of an external field can be a custom serializer which is handwritten, the zero-config serializer for Java and .NET, or previously genereated using the tool. This flag will enable such mixed use cases.
138+
*** In generated code, external types are imported exactly what as the "type" of the field, hence for languages like Java the user should enter the full package name together with the class. E.g. type: `com.app1.dto.Address`.
139+

0 commit comments

Comments
 (0)