v2

package module
v2.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

README

CloudEvents Expression Language Go implementation

CloudEvents Expression Language implementation.

Note: this package is a work in progress, APIs might break in future releases.

User guide

To start using it:

import cesqlparser "github.com/cloudevents/sdk-go/sql/v2/parser"

// Parse the expression
expression, err := cesqlparser.Parse("subject = 'Hello world'")

// Res can be either int32, bool or string
res, err := expression.Evaluate(event)

Development guide

To regenerate the parser, make sure you have ANTLR4 installed and then run:

antlr4 -v 4.10.1 -Dlanguage=Go -package gen -o gen -visitor -no-listener CESQLParser.g4

Then you need to run this sed command as a workaround until this ANTLR issue is resolved. Without this, building for 32bit platforms will throw an int overflow error:

sed -i 's/(1<</(int64(1)<</g' gen/cesqlparser_parser.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

type Expression interface {

	// Evaluate the expression using the provided input type.
	// The return value can be either int32, bool or string.
	// The evaluation fails as soon as an error arises.
	Evaluate(event cloudevents.Event) (interface{}, error)
}

Expression represents a parsed CloudEvents SQL Expression.

type Function

type Function interface {
	Name() string
	Arity() int
	IsVariadic() bool
	ArgType(index int) *Type

	Run(event cloudevents.Event, arguments []interface{}) (interface{}, error)
}

type Type

type Type uint8
const (
	StringType Type = iota
	IntegerType
	BooleanType
	AnyType
)

func TypeFromVal

func TypeFromVal(val interface{}) Type

func TypePtr

func TypePtr(t Type) *Type

func (Type) IsSameType

func (t Type) IsSameType(val interface{}) bool

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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