-
Notifications
You must be signed in to change notification settings - Fork 1
/
internal_schema_registry_options.go
57 lines (43 loc) · 1.38 KB
/
internal_schema_registry_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package gluon
type internalSchemaRegistryOptions struct {
topic string
source string
schemaName string
version int
}
// SchemaRegistryOption set a specific configuration for internal schema registry.
type SchemaRegistryOption interface {
apply(registryOptions *internalSchemaRegistryOptions)
}
type schemaTopicOption string
func (o schemaTopicOption) apply(opts *internalSchemaRegistryOptions) {
opts.topic = string(o)
}
// WithTopic Set a topic name to a message schema.
func WithTopic(s string) SchemaRegistryOption {
return schemaTopicOption(s)
}
type schemaSourceOption string
func (o schemaSourceOption) apply(opts *internalSchemaRegistryOptions) {
opts.source = string(o)
}
// WithSource Set a source to a message schema.
func WithSource(s string) SchemaRegistryOption {
return schemaSourceOption(s)
}
type schemaNameOption string
func (o schemaNameOption) apply(opts *internalSchemaRegistryOptions) {
opts.schemaName = string(o)
}
// WithSchemaName Set the name of the schema stored on the SchemaRegistry.
func WithSchemaName(s string) SchemaRegistryOption {
return schemaNameOption(s)
}
type schemaVersionOption int
func (o schemaVersionOption) apply(opts *internalSchemaRegistryOptions) {
opts.version = int(o)
}
// WithSchemaVersion Set a major version for a message schema.
func WithSchemaVersion(v int) SchemaRegistryOption {
return schemaVersionOption(v)
}