func()

in internal/catalog.go [123:147]


func (c *catalogDALImpl) create(tx *gorm.DB, record *model.Event) error {
	if len(record.Definition) == 0 {
		return nil
	}
	var doc = new(v2.Document)
	if err := v2.Decode(gconv.Bytes(record.Definition), &doc); err != nil {
		return err
	}
	if len(doc.Channels()) == 0 {
		return nil
	}
	var handlers []func() error
	handlers = append(handlers, func() error {
		return c.insertEvent(tx, c.buildEvent(record.Definition, doc))
	})
	for _, channel := range doc.Channels() {
		for _, operation := range channel.Operations() {
			var eventCatalog = c.buildEventCatalog(doc.Info().Title(), channel, operation)
			handlers = append(handlers, func() error {
				return c.insert(tx, eventCatalog)
			})
		}
	}
	return util.GoAndWait(handlers...)
}