Documentation ¶
Index ¶
- Constants
- Variables
- func AliasKindStrings() []string
- func EncodeComments(comments []string) string
- func ModuleToBytes(m *Module) ([]byte, error)
- func Normalise[T Node](n T) T
- func Redact[T Node](n T) T
- func RequestResponseToJSONSchema(sch *Schema, ref Ref) (*jsonschema.Schema, 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, opts ...EncodingOption) 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 AWSIAMAuthDatabaseConnector
- type AliasKind
- type Any
- type Array
- type Bool
- type Bytes
- type Config
- type DSNDatabaseConnector
- type Data
- type Database
- type DatabaseConnector
- type DatabaseRuntime
- type Decl
- type EncodingOption
- type Enum
- type EnumVariant
- type Field
- type Float
- type FromOffset
- type IngressPathComponent
- type IngressPathLiteral
- type IngressPathParameter
- type Int
- type IntValue
- type Map
- type Metadata
- type MetadataAlias
- type MetadataCalls
- type MetadataConfig
- type MetadataCronJob
- type MetadataDatabases
- type MetadataEncoding
- type MetadataIngress
- type MetadataPublisher
- type MetadataRetry
- type MetadataSQLMigration
- type MetadataSecrets
- 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 ModuleRuntime
- type Named
- type Node
- type Optional
- type Position
- type Redactable
- 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) ResolveWithModule(ref *Ref) (optional.Option[Decl], optional.Option[*Module])
- 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 Symbol
- type Time
- type Topic
- type TopicRuntime
- type Type
- type TypeAlias
- type TypeParameter
- type TypeValue
- type Unit
- type Value
- type Verb
- func (v *Verb) AddCall(verb *Ref)
- func (v *Verb) AddConfig(config *Ref)
- func (v *Verb) AddDatabase(db *Ref)
- func (v *Verb) AddSecret(secret *Ref)
- func (v *Verb) AddSubscription(sub *MetadataSubscriber)
- func (v *Verb) AddTopicPublish(topic *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) SortMetadata()
- func (v *Verb) String() string
- func (v *Verb) ToProto() proto.Message
- type VerbKind
- type VerbRuntime
Constants ¶
const ( DefaultRetryCount = 10 MinBackoffLimitStr = "1s" MinBackoffLimit = 1 * time.Second DefaultMaxBackoff = 1 * time.Hour MaxBackoffLimitStr = "1d" MaxBackoffLimit = 24 * time.Hour )
const BuiltinsSource = `` /* 830-byte string literal not displayed */
BuiltinsSource is the schema source code for built-in types.
const MySQLDatabaseType = "mysql"
const PostgresDatabaseType = "postgres"
Variables ¶
var ErrNotFound = errors.New("not found")
var (
Lexer = lexer.MustSimple([]lexer.SimpleRule{
{Name: "EOL", Pattern: `[\r\n]`},
{Name: "SHA256", Pattern: `\b[A-za-z0-9]{64}\b`},
{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 ¶
func AliasKindStrings() []string
AliasKindStrings returns a slice of all String values of the enum
func EncodeComments ¶
func ModuleToBytes ¶
func Normalise ¶
func Normalise[T Node](n T) T
Normalise clones and normalises (zeroes) positional information in schema Nodes.
func Redact ¶ added in v0.384.0
func Redact[T Node](n T) T
Redact clones n and recursively removes sensitive information from it.
Any node that implements the Redactable interface will have its Redact method called.
func RequestResponseToJSONSchema ¶
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 SortModuleDecls ¶
func SortModuleDecls(module *Module)
SortModuleDecls sorts the declarations in a module.
func TransformAliasedFields ¶
func TypeName ¶
TypeName returns the name of a type as a string, stripping any package prefix and correctly handling Ref aliases.
func TypeToProto ¶
TypeToProto creates a schemapb.Type "sum type" from a concreate Type.
func ValidateJSONValue ¶
func ValidateJSONValue(fieldType Type, path path, value any, sch *Schema, opts ...EncodingOption) error
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 ValidateRequestMap ¶
func ValidateRequestMap(ref *Ref, path path, request map[string]any, sch *Schema, opts ...EncodingOption) error
ValidateRequestMap validates a given JSON map against the provided schema.
func VisitExcludingMetadataChildren ¶
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 AWSIAMAuthDatabaseConnector ¶ added in v0.405.0
type AWSIAMAuthDatabaseConnector struct { Pos Position `parser:"" protobuf:"1,optional"` Username string `parser:"" protobuf:"2"` Endpoint string `parser:"" protobuf:"3"` Database string `parser:"" protobuf:"4"` }
func (*AWSIAMAuthDatabaseConnector) Position ¶ added in v0.405.0
func (d *AWSIAMAuthDatabaseConnector) Position() Position
func (*AWSIAMAuthDatabaseConnector) String ¶ added in v0.405.0
func (d *AWSIAMAuthDatabaseConnector) String() string
func (*AWSIAMAuthDatabaseConnector) ToProto ¶ added in v0.405.0
func (d *AWSIAMAuthDatabaseConnector) ToProto() protoreflect.ProtoMessage
type AliasKind ¶
type AliasKind int
AliasKind is the kind of alias.
func AliasKindString ¶
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 ¶
func AliasKindValues() []AliasKind
AliasKindValues returns all values of the enum
func (AliasKind) IsAAliasKind ¶
IsAAliasKind returns "true" if the value is listed in the enum definition. "false" otherwise
func (AliasKind) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for AliasKind
func (AliasKind) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for AliasKind
func (*AliasKind) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for AliasKind
func (*AliasKind) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for AliasKind
type Any ¶
type Array ¶
type Bool ¶
type Bytes ¶
type Config ¶
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 ¶
func (*Config) IsExported ¶
func (*Config) ToProto ¶
func (s *Config) ToProto() protoreflect.ProtoMessage
type DSNDatabaseConnector ¶ added in v0.403.0
type DSNDatabaseConnector struct { Pos Position `parser:"" protobuf:"1,optional"` DSN string `parser:"" protobuf:"2"` }
func (*DSNDatabaseConnector) Position ¶ added in v0.403.0
func (d *DSNDatabaseConnector) Position() Position
func (*DSNDatabaseConnector) String ¶ added in v0.403.0
func (d *DSNDatabaseConnector) String() string
func (*DSNDatabaseConnector) ToProto ¶ added in v0.403.0
func (d *DSNDatabaseConnector) 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 ¶
func (*Data) FieldByName ¶
func (*Data) IsExported ¶
func (*Data) Monomorphise ¶
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 ¶
type Database struct { Pos Position `parser:"" protobuf:"1,optional"` Runtime *DatabaseRuntime `parser:"" protobuf:"31634,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Type string `parser:"'database' @('postgres'|'mysql')" protobuf:"4"` Name string `parser:"@Ident" protobuf:"3"` Metadata []Metadata `parser:"@@*" protobuf:"5"` }
func DatabaseFromProto ¶
func (*Database) IsExported ¶
type DatabaseConnector ¶ added in v0.403.0
type DatabaseConnector interface { Node // contains filtered or unexported methods }
func DatabaseConnectorFromProto ¶ added in v0.403.0
func DatabaseConnectorFromProto(s *schemapb.DatabaseConnector) DatabaseConnector
type DatabaseRuntime ¶ added in v0.384.0
type DatabaseRuntime struct { ReadConnector DatabaseConnector `parser:"" protobuf:"1"` WriteConnector DatabaseConnector `parser:"" protobuf:"2"` }
func DatabaseRuntimeFromProto ¶ added in v0.384.0
func DatabaseRuntimeFromProto(s *schemapb.DatabaseRuntime) *DatabaseRuntime
func (*DatabaseRuntime) Position ¶ added in v0.403.0
func (d *DatabaseRuntime) Position() Position
func (*DatabaseRuntime) String ¶ added in v0.403.0
func (d *DatabaseRuntime) String() string
func (*DatabaseRuntime) ToProto ¶ added in v0.384.0
func (d *DatabaseRuntime) ToProto() protoreflect.ProtoMessage
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 EncodingOption ¶
type EncodingOption func(option *encodingOptions)
func LenientMode ¶
func LenientMode() EncodingOption
type Enum ¶
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 ¶
func (*Enum) IsExported ¶
func (*Enum) IsValueEnum ¶
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 ¶
func (e *Enum) VariantForName(name string) optional.Option[*EnumVariant]
type EnumVariant ¶
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 ¶
func (e *EnumVariant) Position() Position
func (*EnumVariant) String ¶
func (e *EnumVariant) String() string
func (*EnumVariant) ToProto ¶
func (e *EnumVariant) ToProto() proto.Message
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 FromOffset ¶ added in v0.404.0
type FromOffset int
const ( FromOffsetBeginning FromOffset = iota FromOffsetLatest )
func (*FromOffset) Capture ¶ added in v0.404.0
func (o *FromOffset) Capture(values []string) error
func (FromOffset) String ¶ added in v0.404.0
func (o FromOffset) String() string
func (FromOffset) ToProto ¶ added in v0.404.0
func (o FromOffset) ToProto() schemapb.FromOffset
type IngressPathComponent ¶
type IngressPathComponent interface { Node // contains filtered or unexported methods }
type IngressPathLiteral ¶
type IngressPathLiteral struct { Pos Position `parser:"" protobuf:"1,optional"` Text string `parser:"@~(Whitespace | '/' | '{' | '}')+" protobuf:"2"` }
func (*IngressPathLiteral) Position ¶
func (l *IngressPathLiteral) Position() Position
func (*IngressPathLiteral) String ¶
func (l *IngressPathLiteral) String() string
func (*IngressPathLiteral) ToProto ¶
func (l *IngressPathLiteral) ToProto() proto.Message
type IngressPathParameter ¶
type IngressPathParameter struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"'{' @Ident '}'" protobuf:"2"` }
func (*IngressPathParameter) Position ¶
func (l *IngressPathParameter) Position() Position
func (*IngressPathParameter) String ¶
func (l *IngressPathParameter) String() string
func (*IngressPathParameter) ToProto ¶
func (l *IngressPathParameter) ToProto() proto.Message
type Int ¶
type IntValue ¶
type Map ¶
type Metadata ¶
type Metadata interface { Node // contains filtered or unexported methods }
Metadata represents a metadata Node in the schema grammar.
type MetadataAlias ¶
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 ¶
func (m *MetadataAlias) Position() Position
func (*MetadataAlias) String ¶
func (m *MetadataAlias) String() string
func (*MetadataAlias) ToProto ¶
func (m *MetadataAlias) ToProto() protoreflect.ProtoMessage
type MetadataCalls ¶
type MetadataCalls struct { Pos Position `parser:"" protobuf:"1,optional"` Calls []*Ref `parser:"'+' 'calls' @@ (',' @@)*" protobuf:"2"` }
MetadataCalls represents a metadata block with a list of calls.
func (*MetadataCalls) Position ¶
func (m *MetadataCalls) Position() Position
func (*MetadataCalls) String ¶
func (m *MetadataCalls) String() string
func (*MetadataCalls) ToProto ¶
func (m *MetadataCalls) ToProto() proto.Message
type MetadataConfig ¶
type MetadataConfig struct { Pos Position `parser:"" protobuf:"1,optional"` Config []*Ref `parser:"'+' 'config' @@ (',' @@)*" protobuf:"2"` }
MetadataConfig represents a metadata block with a list of config items that are used.
func (*MetadataConfig) Position ¶
func (m *MetadataConfig) Position() Position
func (*MetadataConfig) String ¶
func (m *MetadataConfig) String() string
func (*MetadataConfig) ToProto ¶
func (m *MetadataConfig) ToProto() proto.Message
type MetadataCronJob ¶
type MetadataCronJob struct { Pos Position `parser:"" protobuf:"1,optional"` Cron string `parser:"'+' 'cron' Whitespace @(' ' | ~EOL)+" protobuf:"2"` }
func (*MetadataCronJob) Position ¶
func (m *MetadataCronJob) Position() Position
func (*MetadataCronJob) String ¶
func (m *MetadataCronJob) String() string
func (*MetadataCronJob) ToProto ¶
func (m *MetadataCronJob) ToProto() proto.Message
type MetadataDatabases ¶
type MetadataDatabases struct { Pos Position `parser:"" protobuf:"1,optional"` Calls []*Ref `parser:"'+' 'database' 'calls' @@ (',' @@)*" protobuf:"2"` }
func (*MetadataDatabases) Position ¶
func (m *MetadataDatabases) Position() Position
func (*MetadataDatabases) String ¶
func (m *MetadataDatabases) String() string
func (*MetadataDatabases) ToProto ¶
func (m *MetadataDatabases) ToProto() proto.Message
type MetadataEncoding ¶
type MetadataEncoding struct { Pos Position `parser:"" protobuf:"1,optional"` Type string `parser:"'+' 'encoding' @'json'" protobuf:"2"` Lenient bool `parser:"@'lenient'?" protobuf:"3"` }
func (*MetadataEncoding) Position ¶
func (m *MetadataEncoding) Position() Position
func (*MetadataEncoding) String ¶
func (m *MetadataEncoding) String() string
func (*MetadataEncoding) ToProto ¶
func (m *MetadataEncoding) ToProto() protoreflect.ProtoMessage
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) PathString ¶ added in v0.403.0
func (m *MetadataIngress) PathString() string
PathString returns the path as a string, with parameters enclosed in curly braces.
For example, /foo/{bar}
func (*MetadataIngress) Position ¶
func (m *MetadataIngress) Position() Position
func (*MetadataIngress) String ¶
func (m *MetadataIngress) String() string
func (*MetadataIngress) ToProto ¶
func (m *MetadataIngress) ToProto() proto.Message
type MetadataPublisher ¶ added in v0.398.0
type MetadataPublisher struct { Pos Position `parser:"" protobuf:"1,optional"` Topics []*Ref `parser:"'+' 'publish' @@ (',' @@)*" protobuf:"2"` }
func (*MetadataPublisher) Position ¶ added in v0.398.0
func (m *MetadataPublisher) Position() Position
func (*MetadataPublisher) String ¶ added in v0.398.0
func (m *MetadataPublisher) String() string
func (*MetadataPublisher) ToProto ¶ added in v0.398.0
func (m *MetadataPublisher) ToProto() proto.Message
type MetadataRetry ¶
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 ¶
func (m *MetadataRetry) Position() Position
func (*MetadataRetry) RetryParams ¶
func (m *MetadataRetry) RetryParams() (RetryParams, error)
func (*MetadataRetry) String ¶
func (m *MetadataRetry) String() string
func (*MetadataRetry) ToProto ¶
func (m *MetadataRetry) ToProto() proto.Message
type MetadataSQLMigration ¶ added in v0.399.0
type MetadataSQLMigration struct { Pos Position `parser:"" protobuf:"1,optional"` Digest string `parser:"'+' 'migration' Whitespace 'sha256' ':' @SHA256" protobuf:"2"` }
func (*MetadataSQLMigration) Position ¶ added in v0.399.0
func (m *MetadataSQLMigration) Position() Position
func (*MetadataSQLMigration) String ¶ added in v0.399.0
func (m *MetadataSQLMigration) String() string
func (*MetadataSQLMigration) ToProto ¶ added in v0.399.0
func (m *MetadataSQLMigration) ToProto() proto.Message
type MetadataSecrets ¶
type MetadataSecrets struct { Pos Position `parser:"" protobuf:"1,optional"` Secrets []*Ref `parser:"'+' 'secrets' @@ (',' @@)*" protobuf:"2"` }
MetadataSecrets represents a metadata block with a list of config items that are used.
func (*MetadataSecrets) Position ¶
func (m *MetadataSecrets) Position() Position
func (*MetadataSecrets) String ¶
func (m *MetadataSecrets) String() string
func (*MetadataSecrets) ToProto ¶
func (m *MetadataSecrets) ToProto() proto.Message
type MetadataSubscriber ¶
type MetadataSubscriber struct { Pos Position `parser:"" protobuf:"1,optional"` Topic *Ref `parser:"'+' 'subscribe' @@" protobuf:"2"` FromOffset FromOffset `parser:"'from' '=' @('beginning'|'latest')" protobuf:"3"` DeadLetter bool `parser:"@'deadletter'?" protobuf:"4"` }
func (*MetadataSubscriber) Position ¶
func (m *MetadataSubscriber) Position() Position
func (*MetadataSubscriber) String ¶
func (m *MetadataSubscriber) String() string
func (*MetadataSubscriber) ToProto ¶
func (m *MetadataSubscriber) ToProto() proto.Message
type MetadataTypeMap ¶
type MetadataTypeMap struct { Pos Position `parser:"" protobuf:"1,optional"` Runtime string `parser:"'+' 'typemap' @('go' | 'kotlin' | 'java')" protobuf:"2"` NativeName string `parser:"@String" protobuf:"3"` }
func (*MetadataTypeMap) Position ¶
func (m *MetadataTypeMap) Position() Position
func (*MetadataTypeMap) String ¶
func (m *MetadataTypeMap) String() string
func (*MetadataTypeMap) ToProto ¶
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"` Runtime *ModuleRuntime `protobuf:"31634,optional" parser:""` }
func ModuleFromBytes ¶
func ModuleFromProto ¶
ModuleFromProto converts a protobuf Module to a Module and validates it.
func ModuleFromProtoFile ¶
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 ¶
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 ¶
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 ¶
func (*Module) Resolve ¶
func (m *Module) Resolve(ref Ref) *ModuleDecl
Resolve returns the declaration in this module with the given name, or nil
type ModuleDecl ¶
ModuleDecl is a declaration associated with a module.
func ResolveAs ¶
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 ¶
func ResolveTypeAs[S Symbol](scopes Scopes, t Type) (symbol S, decl *ModuleDecl)
ResolveTypeAs resolves a Type to a concrete symbol and declaration.
type ModuleRuntime ¶
type ModuleRuntime struct { CreateTime time.Time `protobuf:"1"` Language string `protobuf:"2"` MinReplicas int32 `protobuf:"3"` OS string `protobuf:"4,optional"` Arch string `protobuf:"5,optional"` // Image is the name of the runner image. Defaults to "ftl0/ftl-runner". // Must not include a tag, as FTL's version will be used as the tag. Image string `protobuf:"6,optional"` }
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 ¶
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 Position struct { Filename string `protobuf:"1"` Offset int `parser:"" protobuf:"-"` Line int `protobuf:"2"` Column int `protobuf:"3"` }
func PosFromProto ¶
func (Position) ToErrorPos ¶
func (p Position) ToErrorPos() builderrors.Position
func (Position) ToErrorPosWithEnd ¶
func (p Position) ToErrorPosWithEnd(endColumn int) builderrors.Position
type Redactable ¶ added in v0.384.0
type Redactable interface {
Redact()
}
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 ¶
type Resolver ¶
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 ¶
type Schema ¶
type Schema struct { Pos Position `parser:"" protobuf:"1,optional"` Modules []*Module `parser:"@@*" protobuf:"2"` }
func ParseString ¶
func ValidateModuleInSchema ¶
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 ¶
ValidateSchema clones, normalises and semantically validates a schema.
func (*Schema) ResolveMonomorphised ¶
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 ¶
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 ¶
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)
func (*Schema) ResolveWithModule ¶
ResolveWithModule a reference to a declaration and its module.
type Scoped ¶
type Scoped interface {
Scope() Scope
}
Scoped is implemented by nodes that wish to introduce a new scope.
type Scopes ¶
type Scopes []Scope
Scopes to search during type resolution.
func NewScopes ¶
func NewScopes() Scopes
NewScopes constructs a new type resolution stack with builtins pre-populated.
func (Scopes) Push ¶
Push a new Scope onto the stack.
This contains references to previous Scopes so that updates are preserved.
func (Scopes) Resolve ¶
func (s Scopes) Resolve(ref Ref) *ModuleDecl
Resolve a reference to a symbol declaration or nil.
func (Scopes) ResolveType ¶
func (s Scopes) ResolveType(t Type) *ModuleDecl
type Secret ¶
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 ¶
func (*Secret) IsExported ¶
func (*Secret) ToProto ¶
func (s *Secret) ToProto() protoreflect.ProtoMessage
type String ¶
type StringValue ¶
type StringValue struct { Pos Position `parser:"" protobuf:"1,optional"` Value string `parser:"@String" protobuf:"2"` }
func (*StringValue) GetValue ¶
func (s *StringValue) GetValue() any
func (*StringValue) Position ¶
func (s *StringValue) Position() Position
func (*StringValue) String ¶
func (s *StringValue) String() string
func (*StringValue) ToProto ¶
func (s *StringValue) ToProto() proto.Message
type Symbol ¶
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 ¶
type Topic struct { Pos Position `parser:"" protobuf:"1,optional"` Runtime *TopicRuntime `parser:"" protobuf:"31634,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 ¶
func (*Topic) IsExported ¶
type TopicRuntime ¶ added in v0.402.0
type TopicRuntime struct { KafkaBrokers []string `parser:"" protobuf:"1"` TopicID string `parser:"" protobuf:"2"` }
func TopicRuntimeFromProto ¶ added in v0.402.0
func TopicRuntimeFromProto(t *schemapb.TopicRuntime) *TopicRuntime
func (*TopicRuntime) ToProto ¶ added in v0.402.0
func (t *TopicRuntime) ToProto() *schemapb.TopicRuntime
type Type ¶
type Type interface { Node // Equal returns true if this type is equal to another type. Equal(other Type) bool // contains filtered or unexported methods }
Type represents a Type Node in the schema grammar.
func TypeFromProto ¶
type TypeAlias ¶
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 ¶
func (*TypeAlias) IsExported ¶
type TypeParameter ¶
type TypeParameter struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"@Ident" protobuf:"2"` }
func (*TypeParameter) GetName ¶
func (t *TypeParameter) GetName() string
func (*TypeParameter) Position ¶
func (t *TypeParameter) Position() Position
func (*TypeParameter) String ¶
func (t *TypeParameter) String() string
func (*TypeParameter) ToProto ¶
func (t *TypeParameter) ToProto() protoreflect.ProtoMessage
type TypeValue ¶
type Unit ¶
type Unit struct { Pos Position `parser:"" protobuf:"1,optional"` Unit bool `parser:"@'Unit'" protobuf:"-"` }
func (*Unit) ToProto ¶
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"` Runtime *VerbRuntime `protobuf:"31634,optional" parser:""` }
func VerbFromProto ¶
func (*Verb) AddDatabase ¶ added in v0.393.0
AddDatabase adds a DB reference to the Verb.
func (*Verb) AddSubscription ¶ added in v0.401.0
func (v *Verb) AddSubscription(sub *MetadataSubscriber)
func (*Verb) AddTopicPublish ¶ added in v0.401.0
AddTopicPublish adds a topic that this Verb publishes to.
func (*Verb) GetMetadataCronJob ¶
func (v *Verb) GetMetadataCronJob() optional.Option[*MetadataCronJob]
func (*Verb) GetMetadataIngress ¶
func (v *Verb) GetMetadataIngress() optional.Option[*MetadataIngress]
func (*Verb) IsExported ¶
func (*Verb) SortMetadata ¶ added in v0.398.0
func (v *Verb) SortMetadata()
type VerbKind ¶
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
- field.go
- float.go
- int.go
- intvalue.go
- jsonschema.go
- jsonvalidate.go
- map.go
- metadataalias.go
- metadatacalls.go
- metadataconfig.go
- metadatacronjob.go
- metadatadatabases.go
- metadataencoding.go
- metadataingress.go
- metadatapublisher.go
- metadataretry.go
- metadatasecrets.go
- metadatasqlmigration.go
- metadatasubscriber.go
- metadatatypemap.go
- module.go
- normalise.go
- optional.go
- parser.go
- protobuf_dec.go
- protobuf_enc.go
- redact.go
- ref.go
- schema.go
- secret.go
- string.go
- stringvalue.go
- time.go
- topic.go
- typealias.go
- typeparameter.go
- typeresolver.go
- typevalue.go
- unit.go
- validate.go
- verb.go
- visit.go
Directories ¶
Path | Synopsis |
---|---|
Package strcase provides programming case conversion functions for strings.
|
Package strcase provides programming case conversion functions for strings. |