Documentation ¶
Index ¶
Constants ¶
const (
// Topic constants
TopicTodoCreated = "platform.idmsvc.todo-created"
)
Variables ¶
var AllowedTopics = []string{ TopicTodoCreated, }
FIXME Refactor this to make it more dynamic and reduce work for the developer
Functions ¶
This section is empty.
Types ¶
type Schema ¶
type Schema jsonschema.Schema
func LoadSchemaFromString ¶
LoadSchemaFromString unmarshall a schema from its string representation in json format. schemas is a string representation in json format for gojsonschema.Schema. Return the resulting list of schemas, or nil if an an error happens.
func (*Schema) Validate ¶
Validate check that data interface accomplish the Schema. data is any type, it cannot be nil. Return nil if the check is success, else a filled error.
func (*Schema) ValidateBytes ¶
ValidateBytes validate that a slice of bytes which represent an event message match the Schema. data is a byte slice with the event message representation. Return nil if check is success, else a filled error.
type TodoCreatedEventJson ¶
type TodoCreatedEventJson struct { // The Todo description Description string `json:"description" yaml:"description"` // The id of the Todo resource. // Id float64 `json:"id" yaml:"id"` // The Todo title Title string `json:"title" yaml:"title"` }
Message schema for todo creation event
func (*TodoCreatedEventJson) UnmarshalJSON ¶
func (j *TodoCreatedEventJson) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type TopicSchema ¶
func LoadSchemas ¶
func LoadSchemas() (TopicSchema, error)
LoadSchemas unmarshall all the embedded schemas and return all them in the output schemas variable. See also LoadSchemaFromString. schemas is a hashmap map[string]*gojsonschema.Schema that can be used to immediately validate schemas against unmarshalled schemas. Return the resulting list of schemas, or nil if an an error happens.
func (*TopicSchema) GetSchema ¶
func (ts *TopicSchema) GetSchema(topic string) *Schema
GetSchemaMap return a SchemaMap associated to one topic. topic the topic which want to retrieve the SchemaMap. Return a SchemaMap associated to the topic or nil if the topic is not found.
func (*TopicSchema) ValidateMessage ¶
func (ts *TopicSchema) ValidateMessage(msg *kafka.Message) error
ValidateMessage check the msg is accomplish the schema defined for it. msg is a reference to a kafka.Message struct. Return nil if the check is success else an error reference is filled.