Documentation ¶
Index ¶
- Constants
- Variables
- func AliasKindStrings() []string
- func ContainsTerminalError(errs []*Error) bool
- func EncodeComments(comments []string) string
- func ModuleToBytes(m *Module) ([]byte, error)
- func Normalise[T Node](n T) T
- func ProtobufSchema() string
- func RequestResponseToJSONSchema(sch *Schema, ref Ref) (*jsonschema.Schema, error)
- func SortErrorsByPosition(merr []*Error)
- func SortModuleDecls(module *Module)
- func TransformAliasedFields(sch *Schema, t Type, obj any, ...) error
- func TransformFromAliasedFields(ref *Ref, sch *Schema, request map[string]any) (map[string]any, error)
- func TransformToAliasedFields(ref *Ref, sch *Schema, request map[string]any) (map[string]any, error)
- func TypeName(v any) string
- func TypeToProto(t Type) *schemapb.Type
- func ValidateJSONValue(fieldType Type, path path, value any, sch *Schema) error
- func ValidateModule(module *Module) error
- func ValidateName(name string) bool
- func ValidateRequestMap(ref *Ref, path path, request map[string]any, sch *Schema) error
- func Visit(n Node, visit func(n Node, next func() error) error) error
- func VisitExcludingMetadataChildren(n Node, visit func(n Node, next func() error) error) error
- func VisitWithParent(n Node, parent Node, visit func(n Node, parent Node, next func() error) error) error
- type AliasKind
- type Any
- type Array
- type Bool
- type Bytes
- type Config
- type Data
- type Database
- type Decl
- type Enum
- type EnumVariant
- type Error
- func Errorf(pos Position, endColumn int, format string, args ...any) *Error
- func Infof(pos Position, endColumn int, format string, args ...any) *Error
- func Warnf(pos Position, endColumn int, format string, args ...any) *Error
- func Wrapf(pos Position, endColumn int, err error, format string, args ...any) *Error
- type ErrorLevel
- type ErrorList
- type FSM
- type FSMTransition
- type Field
- type Float
- type IngressPathComponent
- type IngressPathLiteral
- type IngressPathParameter
- type Int
- type IntValue
- type Map
- type Metadata
- type MetadataAlias
- type MetadataCalls
- type MetadataCronJob
- type MetadataDatabases
- type MetadataIngress
- type MetadataRetry
- type MetadataSubscriber
- type MetadataTypeMap
- type Module
- func Builtins() *Module
- func ModuleFromBytes(b []byte) (*Module, error)
- func ModuleFromProto(s *schemapb.Module) (*Module, error)
- func ModuleFromProtoFile(filename string) (*Module, error)
- func ParseModule(filename string, r io.Reader) (*Module, error)
- func ParseModuleString(filename, input string) (*Module, error)
- func (m *Module) AddData(data *Data) int
- func (m *Module) AddDecl(decl Decl)
- func (m *Module) AddDecls(decls []Decl)
- func (m *Module) Data() []*Data
- func (m *Module) GetName() string
- func (m *Module) Imports() []string
- func (m *Module) IsExported() bool
- func (m *Module) Position() Position
- func (m *Module) Resolve(ref Ref) *ModuleDecl
- func (m *Module) Scan(src any) error
- func (m *Module) String() string
- func (m *Module) ToProto() proto.Message
- func (m *Module) Value() (driver.Value, error)
- func (m *Module) Verbs() []*Verb
- type ModuleDecl
- type Named
- type Node
- type Optional
- type Position
- type Ref
- type RefKey
- type Resolver
- type RetryParams
- type Schema
- func FromProto(s *schemapb.Schema) (*Schema, error)
- func MustValidate(schema *Schema) *Schema
- func Parse(filename string, r io.Reader) (*Schema, error)
- func ParseString(filename, input string) (*Schema, error)
- func ValidateModuleInSchema(schema *Schema, m optional.Option[*Module]) (*Schema, error)
- func ValidateSchema(schema *Schema) (*Schema, error)
- func (s *Schema) Hash() [sha256.Size]byte
- func (s *Schema) Module(name string) optional.Option[*Module]
- func (s *Schema) Position() Position
- func (s *Schema) Resolve(ref *Ref) optional.Option[Decl]
- func (s *Schema) ResolveMonomorphised(ref *Ref) (*Data, error)
- func (s *Schema) ResolveRequestResponseType(ref *Ref) (Symbol, error)
- func (s *Schema) ResolveToType(ref *Ref, out Decl) error
- func (s *Schema) String() string
- func (s *Schema) ToProto() proto.Message
- func (s *Schema) Upsert(module *Module)
- type Scope
- type Scoped
- type Scopes
- type Secret
- type String
- type StringValue
- type Subscription
- type Symbol
- type Time
- type Topic
- type Type
- type TypeAlias
- type TypeParameter
- type TypeValue
- type Unit
- type Value
- type Verb
- func (v *Verb) AddCall(verb *Ref)
- func (v *Verb) GetMetadataCronJob() optional.Option[*MetadataCronJob]
- func (v *Verb) GetMetadataIngress() optional.Option[*MetadataIngress]
- func (v *Verb) GetName() string
- func (v *Verb) IsExported() bool
- func (v *Verb) Kind() VerbKind
- func (v *Verb) Position() Position
- func (v *Verb) String() string
- func (v *Verb) ToProto() proto.Message
- type VerbKind
Constants ¶
const ( DefaultRetryCount = 10 MinBackoffLimitStr = "1s" MinBackoffLimit = 1 * time.Second DefaultMaxBackoff = 1 * time.Hour MaxBackoffLimitStr = "1d" MaxBackoffLimit = 24 * time.Hour )
const BuiltinsSource = `` /* 690-byte string literal not displayed */
BuiltinsSource is the schema source code for built-in types.
const PostgresDatabaseType = "postgres"
Variables ¶
var ErrNotFound = errors.New("not found")
var (
Lexer = lexer.MustSimple([]lexer.SimpleRule{
{Name: "EOL", Pattern: `[\r\n]`},
{Name: "Whitespace", Pattern: `\s+`},
{Name: "Ident", Pattern: `\b[a-zA-Z_][a-zA-Z0-9_]*\b`},
{Name: "Comment", Pattern: `//.*`},
{Name: "String", Pattern: `"(?:\\.|[^"])*"`},
{Name: "Number", Pattern: `[0-9]+(?:\.[0-9]+)?`},
{Name: "Punct", Pattern: `[%/\-\_:[\]{}<>()*+?.,\\^$|#~!\'@=]`},
})
)
Functions ¶
func AliasKindStrings ¶ added in v0.139.2
func AliasKindStrings() []string
AliasKindStrings returns a slice of all String values of the enum
func ContainsTerminalError ¶ added in v0.247.3
func EncodeComments ¶ added in v0.215.2
func ModuleToBytes ¶ added in v0.111.2
func Normalise ¶
func Normalise[T Node](n T) T
Normalise clones and normalises (zeroes) positional information in schema Nodes.
func ProtobufSchema ¶
func ProtobufSchema() string
ProtobufSchema returns a string containing the equivalent protobuf schema for the FTL schema.
func RequestResponseToJSONSchema ¶ added in v0.309.1
RequestResponseToJSONSchema converts the schema for a Verb request or response object to a JSON Schema.
It takes in the full schema in order to resolve and define references.
func SortErrorsByPosition ¶ added in v0.171.0
func SortErrorsByPosition(merr []*Error)
func SortModuleDecls ¶ added in v0.300.0
func SortModuleDecls(module *Module)
SortModuleDecls sorts the declarations in a module.
func TransformAliasedFields ¶ added in v0.296.3
func TransformFromAliasedFields ¶ added in v0.296.3
func TransformToAliasedFields ¶ added in v0.296.3
func TypeName ¶ added in v0.98.11
TypeName returns the name of a type as a string, stripping any package prefix and correctly handling Ref aliases.
func TypeToProto ¶ added in v0.226.0
TypeToProto creates a schemapb.Type "sum type" from a concreate Type.
func ValidateJSONValue ¶ added in v0.276.3
ValidateJSONValue validates a given JSON value against the provided schema.
func ValidateModule ¶
ValidateModule performs the subset of semantic validation possible on a single module.
It ignores references to other modules.
func ValidateName ¶ added in v0.99.0
ValidateName validates an FTL name.
func ValidateRequestMap ¶ added in v0.276.3
ValidateRequestMap validates a given JSON map against the provided schema.
func VisitExcludingMetadataChildren ¶ added in v0.153.2
VisitExcludingMetadataChildren visits all nodes in the schema except the children of metadata nodes. This is used when generating external modules to avoid adding imports only referenced in the bodies of stubbed verbs.
Types ¶
type AliasKind ¶ added in v0.139.2
type AliasKind int
AliasKind is the kind of alias.
func AliasKindString ¶ added in v0.139.2
AliasKindString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func AliasKindValues ¶ added in v0.139.2
func AliasKindValues() []AliasKind
AliasKindValues returns all values of the enum
func (AliasKind) IsAAliasKind ¶ added in v0.139.2
IsAAliasKind returns "true" if the value is listed in the enum definition. "false" otherwise
func (AliasKind) MarshalJSON ¶ added in v0.139.2
MarshalJSON implements the json.Marshaler interface for AliasKind
func (AliasKind) MarshalText ¶ added in v0.139.2
MarshalText implements the encoding.TextMarshaler interface for AliasKind
func (*AliasKind) UnmarshalJSON ¶ added in v0.139.2
UnmarshalJSON implements the json.Unmarshaler interface for AliasKind
func (*AliasKind) UnmarshalText ¶ added in v0.139.2
UnmarshalText implements the encoding.TextUnmarshaler interface for AliasKind
type Any ¶ added in v0.100.0
type Array ¶
type Bool ¶
type Bytes ¶ added in v0.88.0
type Config ¶ added in v0.146.0
type Config struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Name string `parser:"'config' @Ident" protobuf:"3"` Type Type `parser:"@@" protobuf:"4"` }
func ConfigFromProto ¶ added in v0.146.3
func (*Config) IsExported ¶ added in v0.193.0
func (*Config) ToProto ¶ added in v0.146.0
func (s *Config) ToProto() protoreflect.ProtoMessage
type Data ¶
type Data struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Export bool `parser:"@'export'?" protobuf:"3"` Name string `parser:"'data' @Ident" protobuf:"4"` TypeParameters []*TypeParameter `parser:"( '<' @@ (',' @@)* '>' )?" protobuf:"5"` Fields []*Field `parser:"'{' @@* '}'" protobuf:"6"` Metadata []Metadata `parser:"@@*" protobuf:"7"` }
A Data structure.
func DataFromProto ¶ added in v0.136.0
func (*Data) FieldByName ¶ added in v0.122.0
func (*Data) IsExported ¶ added in v0.193.0
func (*Data) Monomorphise ¶ added in v0.104.0
Monomorphise this data type with the given type arguments.
If this data type has no type parameters, it will be returned as-is.
This will return a new Data structure with all type parameters replaced with the given types.
type Database ¶ added in v0.95.0
type Database struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Type string `parser:"'database' @'postgres'" protobuf:"4"` Name string `parser:"@Ident" protobuf:"3"` }
func DatabaseFromProto ¶ added in v0.136.0
func (*Database) IsExported ¶ added in v0.193.0
type Decl ¶
type Decl interface { Symbol GetName() string IsExported() bool // contains filtered or unexported methods }
Decl represents user-defined data types in the schema grammar.
type Enum ¶ added in v0.136.0
type Enum struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Export bool `parser:"@'export'?" protobuf:"3"` Name string `parser:"'enum' @Ident" protobuf:"4"` Type Type `parser:"(':' @@)?" protobuf:"5,optional"` Variants []*EnumVariant `parser:"'{' @@* '}'" protobuf:"6"` }
func EnumFromProto ¶ added in v0.136.0
func (*Enum) IsExported ¶ added in v0.193.0
func (*Enum) IsValueEnum ¶ added in v0.195.0
IsValueEnum determines whether this is a type or value enum using `e.Type` alone because value enums must always have a unified type across all variants, whereas type enums by definition cannot have a unified type.
func (*Enum) VariantForName ¶ added in v0.216.0
func (e *Enum) VariantForName(name string) optional.Option[*EnumVariant]
type EnumVariant ¶ added in v0.136.0
type EnumVariant struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Name string `parser:"@Ident" protobuf:"3"` Value Value `parser:"(('=' @@) | @@)!" protobuf:"4"` }
func (*EnumVariant) Position ¶ added in v0.136.0
func (e *EnumVariant) Position() Position
func (*EnumVariant) String ¶ added in v0.136.0
func (e *EnumVariant) String() string
func (*EnumVariant) ToProto ¶ added in v0.136.0
func (e *EnumVariant) ToProto() proto.Message
type Error ¶ added in v0.160.0
type Error struct { Msg string `json:"msg" protobuf:"1"` Pos Position `json:"pos" protobuf:"2"` EndColumn int `json:"endCol" protobuf:"3"` Level ErrorLevel `json:"level" protobuf:"4"` }
type ErrorList ¶ added in v0.162.0
type ErrorList struct {
Errors []*Error `json:"errors" protobuf:"1"`
}
func ErrorListFromProto ¶ added in v0.163.0
ErrorListFromProto converts a protobuf ErrorList to an ErrorList.
type FSM ¶ added in v0.200.0
type FSM struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Name string `parser:"'fsm' @Ident " protobuf:"3"` Metadata []Metadata `parser:"@@*" protobuf:"6"` Start []*Ref `parser:"'{' ('start' @@)*" protobuf:"4"` // Start states. Transitions []*FSMTransition `parser:"('transition' @@)* '}'" protobuf:"5"` }
func FSMFromProto ¶ added in v0.200.0
func (*FSM) IsExported ¶ added in v0.200.0
func (*FSM) TerminalStates ¶ added in v0.226.0
TerminalStates returns the terminal states of the FSM.
func (*FSM) ToProto ¶ added in v0.200.0
func (f *FSM) ToProto() protoreflect.ProtoMessage
type FSMTransition ¶ added in v0.200.0
type FSMTransition struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` From *Ref `parser:"@@" protobuf:"3,optional"` To *Ref `parser:"'to' @@" protobuf:"4"` }
func FSMTransitionFromProto ¶ added in v0.200.0
func FSMTransitionFromProto(pb *schemapb.FSMTransition) *FSMTransition
func (*FSMTransition) Position ¶ added in v0.200.0
func (f *FSMTransition) Position() Position
func (*FSMTransition) String ¶ added in v0.200.0
func (f *FSMTransition) String() string
func (*FSMTransition) ToProto ¶ added in v0.200.0
func (f *FSMTransition) ToProto() protoreflect.ProtoMessage
type Field ¶
type Field struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"3"` Name string `parser:"@Ident" protobuf:"2"` Type Type `parser:"@@" protobuf:"4"` Metadata []Metadata `parser:"@@*" protobuf:"5"` }
type Float ¶
type IngressPathComponent ¶ added in v0.85.5
type IngressPathComponent interface { Node // contains filtered or unexported methods }
type IngressPathLiteral ¶ added in v0.85.5
type IngressPathLiteral struct { Pos Position `parser:"" protobuf:"1,optional"` Text string `parser:"@~(Whitespace | '/' | '{' | '}')+" protobuf:"2"` }
func (*IngressPathLiteral) Position ¶ added in v0.100.0
func (l *IngressPathLiteral) Position() Position
func (*IngressPathLiteral) String ¶ added in v0.85.5
func (l *IngressPathLiteral) String() string
func (*IngressPathLiteral) ToProto ¶ added in v0.85.5
func (l *IngressPathLiteral) ToProto() proto.Message
type IngressPathParameter ¶ added in v0.85.5
type IngressPathParameter struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"'{' @Ident '}'" protobuf:"2"` }
func (*IngressPathParameter) Position ¶ added in v0.100.0
func (l *IngressPathParameter) Position() Position
func (*IngressPathParameter) String ¶ added in v0.85.5
func (l *IngressPathParameter) String() string
func (*IngressPathParameter) ToProto ¶ added in v0.85.5
func (l *IngressPathParameter) ToProto() proto.Message
type Int ¶
type IntValue ¶ added in v0.136.0
type Map ¶
type Metadata ¶
type Metadata interface { Node // contains filtered or unexported methods }
Metadata represents a metadata Node in the schema grammar.
type MetadataAlias ¶ added in v0.139.2
type MetadataAlias struct { Pos Position `parser:"" protobuf:"1,optional"` Kind AliasKind `parser:"'+' 'alias' @Ident" protobuf:"2"` Alias string `parser:"@String" protobuf:"3"` }
func (*MetadataAlias) Position ¶ added in v0.139.2
func (m *MetadataAlias) Position() Position
func (*MetadataAlias) String ¶ added in v0.139.2
func (m *MetadataAlias) String() string
func (*MetadataAlias) ToProto ¶ added in v0.139.2
func (m *MetadataAlias) ToProto() protoreflect.ProtoMessage
type MetadataCalls ¶
type MetadataCalls struct { Pos Position `parser:"" protobuf:"1,optional"` Calls []*Ref `parser:"'+' 'calls' @@ (',' @@)*" protobuf:"2"` }
func (*MetadataCalls) Position ¶ added in v0.100.0
func (m *MetadataCalls) Position() Position
func (*MetadataCalls) String ¶
func (m *MetadataCalls) String() string
func (*MetadataCalls) ToProto ¶
func (m *MetadataCalls) ToProto() proto.Message
type MetadataCronJob ¶ added in v0.165.0
type MetadataCronJob struct { Pos Position `parser:"" protobuf:"1,optional"` Cron string `parser:"'+' 'cron' Whitespace @(' ' | ~EOL)+" protobuf:"2"` }
func (*MetadataCronJob) Position ¶ added in v0.165.0
func (m *MetadataCronJob) Position() Position
func (*MetadataCronJob) String ¶ added in v0.165.0
func (m *MetadataCronJob) String() string
func (*MetadataCronJob) ToProto ¶ added in v0.165.0
func (m *MetadataCronJob) ToProto() proto.Message
type MetadataDatabases ¶ added in v0.95.0
type MetadataDatabases struct { Pos Position `parser:"" protobuf:"1,optional"` Calls []*Ref `parser:"'+' 'database' 'calls' @@ (',' @@)*" protobuf:"2"` }
func (*MetadataDatabases) Position ¶ added in v0.100.0
func (m *MetadataDatabases) Position() Position
func (*MetadataDatabases) String ¶ added in v0.95.0
func (m *MetadataDatabases) String() string
func (*MetadataDatabases) ToProto ¶ added in v0.95.0
func (m *MetadataDatabases) ToProto() proto.Message
type MetadataIngress ¶
type MetadataIngress struct { Pos Position `parser:"" protobuf:"1,optional"` Type string `parser:"'+' 'ingress' @('http')?" protobuf:"2"` Method string `parser:"@('GET' | 'POST' | 'PUT' | 'DELETE')" protobuf:"3"` Path []IngressPathComponent `parser:"('/' @@)+" protobuf:"4"` }
func (*MetadataIngress) Position ¶ added in v0.100.0
func (m *MetadataIngress) Position() Position
func (*MetadataIngress) String ¶
func (m *MetadataIngress) String() string
func (*MetadataIngress) ToProto ¶
func (m *MetadataIngress) ToProto() proto.Message
type MetadataRetry ¶ added in v0.221.0
type MetadataRetry struct { Pos Position `parser:"" protobuf:"1,optional"` Count *int `parser:"'+' 'retry' (@Number Whitespace)?" protobuf:"2,optional"` MinBackoff string `parser:"@(Number (?! Whitespace) Ident)?" protobuf:"3"` MaxBackoff string `parser:"@(Number (?! Whitespace) Ident)?" protobuf:"4"` Catch *Ref `parser:"('catch' @@)?" protobuf:"5,optional"` }
func (*MetadataRetry) Position ¶ added in v0.221.0
func (m *MetadataRetry) Position() Position
func (*MetadataRetry) RetryParams ¶ added in v0.229.0
func (m *MetadataRetry) RetryParams() (RetryParams, error)
func (*MetadataRetry) String ¶ added in v0.221.0
func (m *MetadataRetry) String() string
func (*MetadataRetry) ToProto ¶ added in v0.221.0
func (m *MetadataRetry) ToProto() proto.Message
type MetadataSubscriber ¶ added in v0.232.0
type MetadataSubscriber struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"'+' 'subscribe' @Ident" protobuf:"2"` }
func (*MetadataSubscriber) Position ¶ added in v0.232.0
func (m *MetadataSubscriber) Position() Position
func (*MetadataSubscriber) String ¶ added in v0.232.0
func (m *MetadataSubscriber) String() string
func (*MetadataSubscriber) ToProto ¶ added in v0.232.0
func (m *MetadataSubscriber) ToProto() proto.Message
type MetadataTypeMap ¶ added in v0.282.0
type MetadataTypeMap struct { Pos Position `parser:"" protobuf:"1,optional"` Runtime string `parser:"'+' 'typemap' @('go' | 'kotlin')" protobuf:"2"` NativeName string `parser:"@String" protobuf:"3"` }
func (*MetadataTypeMap) Position ¶ added in v0.282.0
func (m *MetadataTypeMap) Position() Position
func (*MetadataTypeMap) String ¶ added in v0.282.0
func (m *MetadataTypeMap) String() string
func (*MetadataTypeMap) ToProto ¶ added in v0.282.0
func (m *MetadataTypeMap) ToProto() protoreflect.ProtoMessage
type Module ¶
type Module struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Builtin bool `parser:"@'builtin'?" protobuf:"3"` Name string `parser:"'module' @Ident '{'" protobuf:"4"` Decls []Decl `parser:"@@* '}'" protobuf:"5"` }
func Builtins ¶ added in v0.89.0
func Builtins() *Module
Builtins returns a Module containing built-in types.
func ModuleFromBytes ¶
func ModuleFromProto ¶
ModuleFromProto converts a protobuf Module to a Module and validates it.
func ModuleFromProtoFile ¶ added in v0.134.1
ModuleFromProtoFile loads a module from the given proto-encoded file.
func ParseModuleString ¶
func (*Module) AddData ¶
AddData and return its index.
If data is already in the module, the existing index is returned. If the new data is exported but the existing data is not, it sets it to being exported.
func (*Module) AddDecl ¶ added in v0.247.3
AddDecl adds a single decl to the module.
It is only added if not already present or if it changes the visibility of the existing Decl.
func (*Module) AddDecls ¶ added in v0.247.3
AddDecls appends decls to the module.
Decls are only added if they are not already present in the module or if they change the visibility of an existing Decl.
func (*Module) IsExported ¶ added in v0.193.0
func (*Module) Resolve ¶ added in v0.100.0
func (m *Module) Resolve(ref Ref) *ModuleDecl
Resolve returns the declaration in this module with the given name, or nil
type ModuleDecl ¶ added in v0.100.0
ModuleDecl is a declaration associated with a module.
func ResolveAs ¶ added in v0.157.0
func ResolveAs[S Symbol](scopes Scopes, ref Ref) (symbol S, decl *ModuleDecl)
ResolveAs resolves a Ref to a concrete symbol and declaration.
[decl] will be non-nil if the symbol is found, regardless of its type. [symbol] will be non-nil if the symbol is of type [S].
func ResolveTypeAs ¶ added in v0.157.0
func ResolveTypeAs[S Symbol](scopes Scopes, t Type) (symbol S, decl *ModuleDecl)
ResolveTypeAs resolves a Type to a concrete symbol and declaration.
type Node ¶
type Node interface { String() string ToProto() proto.Message Position() Position // contains filtered or unexported methods }
A Node in the schema grammar.
type Optional ¶ added in v0.78.0
type Optional struct { Pos Position `parser:"" protobuf:"1,optional"` Type Type `parser:"@@" protobuf:"2,optional"` }
Optional represents a Type whose value may be optional.
type Position ¶
type Ref ¶
type Ref struct { Pos Position `parser:"" protobuf:"1,optional"` Module string `parser:"(@Ident '.')?" protobuf:"3"` Name string `parser:"@Ident" protobuf:"2"` // Only used for data references. TypeParameters []Type `parser:"[ '<' @@ (',' @@)* '>' ]" protobuf:"4"` }
Ref is an untyped reference to a symbol.
func RefFromProto ¶ added in v0.149.0
type Resolver ¶ added in v0.100.0
type Resolver interface { // Resolve a reference to a symbol declaration or nil. Resolve(ref Ref) *ModuleDecl }
Resolver may be implemented be a node in the AST to resolve references within itself.
type RetryParams ¶ added in v0.229.0
type RetryParams struct { Count int MinBackoff time.Duration MaxBackoff time.Duration Catch optional.Option[RefKey] }
func RetryParamsForFSMTransition ¶ added in v0.229.0
func RetryParamsForFSMTransition(fsm *FSM, verb *Verb) (RetryParams, error)
RetryParamsForFSMTransition finds the retry metadata for the given transition and returns the retry count, min and max backoff.
type Schema ¶
type Schema struct { Pos Position `parser:"" protobuf:"1,optional"` Modules []*Module `parser:"@@*" protobuf:"2"` }
func MustValidate ¶ added in v0.89.0
MustValidate panics if a schema is invalid.
This is useful for testing.
func ParseString ¶
func ValidateModuleInSchema ¶ added in v0.164.1
ValidateModuleInSchema clones and normalises a schema and semantically validates a single module within it. If no module is provided, all modules in the schema are validated.
func ValidateSchema ¶ added in v0.164.1
ValidateSchema clones, normalises and semantically validates a schema.
func (*Schema) ResolveMonomorphised ¶ added in v0.225.0
ResolveMonomorphised resolves a reference to a monomorphised Data type. Also supports resolving the monomorphised Data type underlying a TypeAlias, where applicable.
If a Ref is not found, returns ErrNotFound.
func (*Schema) ResolveRequestResponseType ¶ added in v0.309.1
ResolveRequestResponseType resolves a reference to a supported request/response type, which can be a Data or an Any, or a TypeAlias over either supported type.
func (*Schema) ResolveToType ¶ added in v0.225.0
ResolveToType resolves a reference to a declaration of the given type.
The out parameter must be a pointer to a non-nil Decl implementation or this will panic.
data := &Data{} err := s.ResolveToType(ref, data)
type Scope ¶ added in v0.100.0
type Scope map[string]ModuleDecl
Scope maps relative names to fully qualified types.
type Scoped ¶ added in v0.101.0
type Scoped interface {
Scope() Scope
}
Scoped is implemented by nodes that wish to introduce a new scope.
type Scopes ¶ added in v0.100.0
type Scopes []Scope
Scopes to search during type resolution.
func NewScopes ¶ added in v0.100.0
func NewScopes() Scopes
NewScopes constructs a new type resolution stack with builtins pre-populated.
func (Scopes) Push ¶ added in v0.100.0
Push a new Scope onto the stack.
This contains references to previous Scopes so that updates are preserved.
func (Scopes) Resolve ¶ added in v0.100.0
func (s Scopes) Resolve(ref Ref) *ModuleDecl
Resolve a reference to a symbol declaration or nil.
func (Scopes) ResolveType ¶ added in v0.157.0
func (s Scopes) ResolveType(t Type) *ModuleDecl
type Secret ¶ added in v0.146.0
type Secret struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Name string `parser:"'secret' @Ident" protobuf:"3"` Type Type `parser:"@@" protobuf:"4"` }
func SecretFromProto ¶ added in v0.146.3
func (*Secret) IsExported ¶ added in v0.193.0
func (*Secret) ToProto ¶ added in v0.146.0
func (s *Secret) ToProto() protoreflect.ProtoMessage
type String ¶
type StringValue ¶ added in v0.136.0
type StringValue struct { Pos Position `parser:"" protobuf:"1,optional"` Value string `parser:"@String" protobuf:"2"` }
func (*StringValue) GetValue ¶ added in v0.153.0
func (s *StringValue) GetValue() any
func (*StringValue) Position ¶ added in v0.136.0
func (s *StringValue) Position() Position
func (*StringValue) String ¶ added in v0.136.0
func (s *StringValue) String() string
func (*StringValue) ToProto ¶ added in v0.136.0
func (s *StringValue) ToProto() proto.Message
type Subscription ¶ added in v0.232.0
type Subscription struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Name string `parser:"'subscription' @Ident" protobuf:"3"` Topic *Ref `parser:"@@" protobuf:"4"` }
func SubscriptionFromProto ¶ added in v0.232.0
func SubscriptionFromProto(s *schemapb.Subscription) *Subscription
func (*Subscription) GetName ¶ added in v0.232.0
func (s *Subscription) GetName() string
func (*Subscription) IsExported ¶ added in v0.232.0
func (s *Subscription) IsExported() bool
func (*Subscription) Position ¶ added in v0.232.0
func (s *Subscription) Position() Position
func (*Subscription) String ¶ added in v0.232.0
func (s *Subscription) String() string
func (*Subscription) ToProto ¶ added in v0.232.0
func (s *Subscription) ToProto() proto.Message
type Symbol ¶ added in v0.149.2
type Symbol interface { Node // contains filtered or unexported methods }
Symbol represents a symbol in the schema grammar.
A Symbol is a named type that can be referenced by other types. This includes user defined data types such as data structures and enums, and builtin types.
type Time ¶
type Topic ¶ added in v0.232.0
type Topic struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Export bool `parser:"@'export'?" protobuf:"3"` Name string `parser:"'topic' @Ident" protobuf:"4"` Event Type `parser:"@@" protobuf:"5"` }
func TopicFromProto ¶ added in v0.232.0
func (*Topic) IsExported ¶ added in v0.232.0
type Type ¶
Type represents a Type Node in the schema grammar.
func TypeFromProto ¶ added in v0.226.0
type TypeAlias ¶ added in v0.216.0
type TypeAlias struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Export bool `parser:"@'export'?" protobuf:"3"` Name string `parser:"'typealias' @Ident" protobuf:"4"` Type Type `parser:"@@" protobuf:"5"` Metadata []Metadata `parser:"@@*" protobuf:"6"` }
func TypeAliasFromProto ¶ added in v0.216.0
func (*TypeAlias) IsExported ¶ added in v0.216.0
type TypeParameter ¶ added in v0.101.0
type TypeParameter struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"@Ident" protobuf:"2"` }
func (*TypeParameter) GetName ¶ added in v0.140.0
func (t *TypeParameter) GetName() string
func (*TypeParameter) Position ¶ added in v0.101.0
func (t *TypeParameter) Position() Position
func (*TypeParameter) String ¶ added in v0.101.0
func (t *TypeParameter) String() string
func (*TypeParameter) ToProto ¶ added in v0.101.0
func (t *TypeParameter) ToProto() protoreflect.ProtoMessage
type TypeValue ¶ added in v0.190.0
type Unit ¶ added in v0.94.0
type Unit struct { Pos Position `parser:"" protobuf:"1,optional"` Unit bool `parser:"@'Unit'" protobuf:"-"` }
func (*Unit) ToProto ¶ added in v0.94.0
func (u *Unit) ToProto() protoreflect.ProtoMessage
type Verb ¶
type Verb struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Export bool `parser:"@'export'?" protobuf:"3"` Name string `parser:"'verb' @Ident" protobuf:"4"` Request Type `parser:"'(' @@ ')'" protobuf:"5"` Response Type `parser:"@@" protobuf:"6"` Metadata []Metadata `parser:"@@*" protobuf:"7"` }
func VerbFromProto ¶ added in v0.136.0
func (*Verb) GetMetadataCronJob ¶ added in v0.165.0
func (v *Verb) GetMetadataCronJob() optional.Option[*MetadataCronJob]
func (*Verb) GetMetadataIngress ¶ added in v0.91.0
func (v *Verb) GetMetadataIngress() optional.Option[*MetadataIngress]
func (*Verb) IsExported ¶ added in v0.193.0
type VerbKind ¶ added in v0.202.0
type VerbKind string
VerbKind is the kind of Verb: verb, sink, source or empty.
const ( // VerbKindVerb is a normal verb taking an input and an output of any non-unit type. VerbKindVerb VerbKind = "verb" // VerbKindSink is a verb that takes an input and returns unit. VerbKindSink VerbKind = "sink" // VerbKindSource is a verb that returns an output and takes unit. VerbKindSource VerbKind = "source" // VerbKindEmpty is a verb that takes unit and returns unit. VerbKindEmpty VerbKind = "empty" )
Source Files ¶
- aliaskind_enumer.go
- any.go
- array.go
- bool.go
- builtin.go
- bytes.go
- config.go
- data.go
- database.go
- encoding.go
- enum.go
- errors.go
- field.go
- float.go
- fsm.go
- int.go
- intvalue.go
- jsonschema.go
- jsonvalidate.go
- map.go
- metadataalias.go
- metadatacalls.go
- metadatacronjob.go
- metadatadatabases.go
- metadataingress.go
- metadataretry.go
- metadatasubscriber.go
- metadatatypemap.go
- module.go
- normalise.go
- optional.go
- parser.go
- protobuf.go
- protobuf_dec.go
- protobuf_enc.go
- ref.go
- schema.go
- secret.go
- string.go
- stringvalue.go
- subscription.go
- time.go
- topic.go
- typealias.go
- typeparameter.go
- typeresolver.go
- typevalue.go
- unit.go
- validate.go
- verb.go
- visit.go