Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

How to write and use templates with package #1028

Answered by owulveryck
owulveryck asked this question in Q&A
Discussion options

You must be logged in to vote

Here is a working example:

package event

// Definition of the envelop
#Envelop: {
	subject:          =~"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" // a uuid
	source:           =~"^net.mycompany.+"
	type:             =~"^net.mycompany.+:[cud]" // c : create u : update d : delete
	dataContentType?: string
}

#Data: {}

#Event: {
	envelop: #Envelop
	data:    #Data
}

and the schema for the producer:

package sample1

import (
	"github.com/mycompany/masterschema/schemas/event:event"
)

#Schema: {
	envelop: event.#Envelop & {
		source: "net.mycompany.sample1"
	}
	data: {
		data1: string
	}
}

And a sample data:

message: #Schema & {
	envelop: {
		type:    "ne…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@owulveryck
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@myitcv
Comment options

Answer selected by owulveryck
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants