Help us shape the future of Go! Take the 2026 Go Developer Survey

dsl

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Model the Model
	Model = iota + 1
	// Flow the Data Flow
	Flow
	// HTTP RESTFul API
	HTTP
	// MQTT MQTT API
	MQTT
	// MySQL the MySQL connector
	MySQL
	// PgSQL the PostgreSQL connector
	PgSQL
	// TiDB the TiDB connector
	TiDB
	// Oracle the Oracle connector
	Oracle
	// ClickHouse the ClickHouse connector
	ClickHouse
	// SQLite the SQLite3 connector
	SQLite
	// Elastic the Elastic connector
	Elastic
	// Redis the Redis connector
	Redis
	// MongoDB the MongoDB connector
	MongoDB
	// Kafka the Kafka connector
	Kafka
	// WebSocket the WebSocket service
	WebSocket
	// Socket the Socket service
	Socket
	// Store the Store service
	Store
	// Queue the Queue service
	Queue
	// Schedule the schedule programs
	Schedule
	// Brain the behaviors of Brain (?a group of processes)
	Brain
	// Module the Cloud Module
	Module
	// Component the Cloud Component
	Component
	// Template the DSL template
	Template
)
View Source
const (
	// CREATE the DSL file create event
	CREATE = iota
	// CHANGE the DSL file change event
	CHANGE
	// REMOVE the DSL file remove event
	REMOVE
)

Variables

View Source
var DirTypes = map[string][]int{
	"/apis":       {HTTP, MQTT},
	"/models":     {Model},
	"/flows":      {Flow},
	"/connectors": {MySQL, PgSQL, Oracle, TiDB, SQLite, ClickHouse, Redis, MongoDB, Elastic},
	"/services":   {Socket, WebSocket, Store, Queue},
	"/schedules":  {Schedule},
	"/components": {Component},
	"/templates":  {Template},
}

DirTypes the directories for different types of DSL

View Source
var ExtensionTypes = map[string]int{
	"model":      Model,
	"mod":        Model,
	"flow":       Flow,
	"flw":        Flow,
	"http":       HTTP,
	"mqtt":       MQTT,
	"mysql":      MySQL,
	"my":         MySQL,
	"pgsql":      PgSQL,
	"pg":         PgSQL,
	"db":         SQLite,
	"tidb":       TiDB,
	"oracle":     Oracle,
	"click":      ClickHouse,
	"clickhouse": ClickHouse,
	"redis":      Redis,
	"mongo":      MongoDB,
	"es":         Elastic,
	"kafka":      Kafka,
	"ws":         WebSocket,
	"webs":       WebSocket,
	"sock":       Socket,
	"socket":     Socket,
	"store":      Store,
	"queue":      Queue,
	"que":        Queue,
	"module":     Module,
	"m":          Module,
	"com":        Component,
	"c":          Component,
	"sch":        Schedule,
	"schedule":   Schedule,
	"tpl":        Template,
	"tmpl":       Template,
}

ExtensionTypes the extension types

View Source
var TypeDirs = map[int]string{
	HTTP:       "/apis",
	MQTT:       "/apis",
	Model:      "/models",
	Flow:       "/flows",
	SQLite:     "/connectors",
	MySQL:      "/connectors",
	PgSQL:      "/connectors",
	Oracle:     "/connectors",
	TiDB:       "/connectors",
	ClickHouse: "/connectors",
	Elastic:    "/connectors",
	Redis:      "/connectors",
	MongoDB:    "/connectors",
	Socket:     "/services",
	WebSocket:  "/services",
	Store:      "/services",
	Queue:      "/services",
	Schedule:   "/schedules",
	Component:  "/components",
	Template:   "/templates",
}

TypeDirs the root of different types of DSL

View Source
var TypeExtensions = map[int]string{
	HTTP:       "http",
	MQTT:       "mqtt",
	Model:      "mod",
	Flow:       "flow",
	MySQL:      "mysql",
	PgSQL:      "pgsql",
	Oracle:     "oracle",
	TiDB:       "tidb",
	ClickHouse: "click",
	SQLite:     "db",
	Redis:      "redis",
	MongoDB:    "mongo",
	Socket:     "sock",
	WebSocket:  "webs",
	Store:      "store",
	Queue:      "que",
	Schedule:   "sch",
	Component:  "com",
	Template:   "tpl",
	Elastic:    "es",
}

TypeExtensions the DSL file extensions

Functions

func Scan

func Scan(path string, exclude ...string)

Scan the DSL files

func ScanBin

func ScanBin(path string, exclude ...string)

ScanBin scan the DSL files in binary

func ScanBinPrefix

func ScanBinPrefix(prefix string, path string, exclude ...string)

ScanBinPrefix scan the DSL files in binary

func ScanPrefix

func ScanPrefix(prefix string, path string, exclude ...string)

ScanPrefix Scan the DSL files

Types

type Command

type Command struct {
	DELETE  []string                   // remove the given fields
	MERGE   []map[string]interface{}   // merge fields with the given values (not deep merge)
	REPLACE []map[string]interface{}   // replace the fields with the new definition
	APPEND  []map[string][]interface{} // append to the array fields with the given values
}

Command the DSL command

type DSL

type DSL interface {
	DSLCompile(root string, file string, source map[string]interface{}) error
	DSLCheck(source map[string]interface{}) error
	DSLRefresh(root string, file string, source map[string]interface{}) error
	DSLRemove(root string, file string) error
}

DSL the YAO domain specific language interface

func NewDSL

func NewDSL(kind int) (DSL, error)

NewDSL create DSL with type

type Head struct {
	File    string          // the DSL file path
	Name    string          // the name of the DSL
	Bindata bool            // is saved in bindata
	Type    int             // which type of the DSL
	Lang    *semver.Version // the DSL LANG version
	Version *semver.Version // the DSL version
	From    string          // inherited from
	Run     *Command        // MERGE COMMAND
}

Head the YAO domain specific language Head

func NewHead

func NewHead() *Head

NewHead create a new head of yao

func (*Head) NewVersion

func (head *Head) NewVersion(ver interface{}) (*semver.Version, error)

NewVersion any to version

func (*Head) SetCommand

func (head *Head) SetCommand(cmd interface{}) error

SetCommand set the command of DSL

func (*Head) SetFile

func (head *Head) SetFile(file string) error

SetFile parse file path and set the name and kind

func (*Head) SetFrom

func (head *Head) SetFrom(from interface{}) bool

SetFrom set the from

func (*Head) SetLang

func (head *Head) SetLang(lang interface{}) error

SetLang set the YAO DSL version

func (*Head) SetName

func (head *Head) SetName(name string)

SetName set the name of DSL

func (*Head) SetType

func (head *Head) SetType(kind int)

SetType set the type of DSL

func (*Head) SetVersion

func (head *Head) SetVersion(version interface{}) error

SetVersion set the CURRENT DSL version

type YAO

type YAO struct {
	Head     *Head
	Content  map[string]interface{}
	Compiled map[string]interface{}
	DSL      DSL
	Workshop *workshop.Workshop // DSL workshop
	Trace    []string           // FROM Trace

	Mode string // ? development | production
	// contains filtered or unexported fields
}

YAO the YAO DSL

func New

func New(workshop *workshop.Workshop) *YAO

New create a new YAO DSL

func (*YAO) Bytes

func (yao *YAO) Bytes() ([]byte, error)

Bytes to bytes

func (*YAO) Check

func (yao *YAO) Check() error

Check DSL

func (*YAO) Compile

func (yao *YAO) Compile() error

Compile compile the content

func (*YAO) Download

func (yao *YAO) Download()

Download download the JSON file from workshop to vendor

func (*YAO) On

func (yao *YAO) On(event int, file string) error

On the DSL file change

func (*YAO) Open

func (yao *YAO) Open(file string) error

Open open YAO DSL file

func (*YAO) Refresh

func (yao *YAO) Refresh() error

Refresh DSL

func (*YAO) Remove

func (yao *YAO) Remove() error

Remove DSL

func (*YAO) Save

func (yao *YAO) Save() error

Save export jsonc text and save to file

func (*YAO) SaveAs

func (yao *YAO) SaveAs(file string) error

SaveAs export jsonc text and save to file

func (*YAO) Source

func (yao *YAO) Source(source []byte) error

Source load DSL from source

func (*YAO) UnmarshalJSON

func (yao *YAO) UnmarshalJSON(data []byte) error

UnmarshalJSON for json

Directories

Path Synopsis
u

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL