Skip to content

Commit

Permalink
add more info to usage of generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Sep 25, 2023
1 parent 5372c72 commit 4dc089a
Showing 1 changed file with 94 additions and 1 deletion.
95 changes: 94 additions & 1 deletion base/commands/serializer/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,100 @@ Generates compact serializer from the given schema and for the given programming
long := `
Generates compact serializer from the given schema and for the given programming language.
You can use this command to automatically generate compact serializers instead of implementing them.
See: https://docs.hazelcast.com/hazelcast/5.3/serialization/compact-serialization#implementing-compactserializer
See: https://docs.hazelcast.com/hazelcast/latest/serialization/compact-serialization#implementing-compactserializer
A schema allows you to:
- describe the contents of a compact class using supported field types
- import other schema
- specify a namespaces for schema files and reference other namespaces
- define cyclic references between classes
- reference classes that are not present in the given schemas
A schema is written in YAML.Schema format is given below:
namespace: <namespace of the class>
# note that other schema files can be imported with relative path to this yaml file
imports:
- someOtherSchema.yaml
# All objects in this file will share the same namespace.
classes:
- name: <name of the class>
fields:
- name: <field name>
type: <field type>
external: bool # to mark external types (external to this yaml file)
- namespace: 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.
- imports: 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.
- classes: Used to define classes in the schema
- name: Name of the class
- fields: Fields of the class
- name: Name of the field
- 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:
- boolean
- boolean[]
- int8
- int8[]
- int16
- int16[]
- int32
- int32[]
- int64
- int64[]
- float32
- float32[]
- float64
- float64[]
- string
- string[]
- date
- date[]
- time
- time[]
- timestamp
- timestamp[]
- timestampWithTimezone
- timestampWithTimezone[]
- nullableBoolean
- nullableBoolean[]
- nullableInt8
- nullableInt8[]
- nullableInt16
- nullableInt16[]
- nullableInt32
- nullableInt32[]
- nullableInt64
- nullableInt64[]
- nullableFloat32
- nullableFloat32[]
- nullableFloat64
- nullableFloat64[]
- <OtherCompactClass[]>
- external: 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.
The serializer of an external field can be a custom serializer which is hand written,
the zero-config serializer for Java and .NET, or previously generated using the tool.
This flag will enable such mixed use cases.
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
`
cc.SetCommandHelp(long, short)
cc.AddStringFlag(flagLanguage, "l", "", true, "programming language to use for the generated code")
Expand Down

0 comments on commit 4dc089a

Please sign in to comment.