est

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package est provides the Encore Syntax Tree (EST).

It is an Encore-specific syntax tree that represents the higher-level representation of the application that Encore understands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessType

type AccessType string
const (
	Public  AccessType = "public"
	Private AccessType = "private"
	// Auth is like public but requires authentication.
	Auth AccessType = "auth"
)

type Application

type Application struct {
	ModulePath   string
	Packages     []*Package
	Services     []*Service
	CronJobs     []*CronJob
	PubSubTopics []*PubSubTopic
	Decls        []*schema.Decl
	AuthHandler  *AuthHandler
}

type AuthHandler

type AuthHandler struct {
	Svc    *Service
	Name   string
	Doc    string
	Func   *ast.FuncDecl
	File   *File
	Params *schema.Type // builtin string or named type

	// AuthData is the custom auth data type the app may specify
	// as part of the returns from the auth handler.
	// It is nil if no such auth data type is specified.
	AuthData *Param
}

type CronJob added in v0.19.0

type CronJob struct {
	ID       string
	Title    string
	Doc      string
	Schedule string
	RPC      *RPC
	DeclFile *File
	AST      *ast.Ident
}

func (*CronJob) AllowOnlyParsedUsage added in v1.3.0

func (cj *CronJob) AllowOnlyParsedUsage() bool

func (*CronJob) File added in v1.3.0

func (cj *CronJob) File() *File

func (*CronJob) Ident added in v1.3.0

func (cj *CronJob) Ident() *ast.Ident

func (*CronJob) IsValid added in v0.19.0

func (cj *CronJob) IsValid() (bool, error)

func (*CronJob) NodeType added in v1.3.0

func (cj *CronJob) NodeType() NodeType

func (*CronJob) Type added in v1.3.0

func (cj *CronJob) Type() ResourceType

type File

type File struct {
	Name       string   // file name ("foo.go")
	Pkg        *Package // package it belongs to
	Path       string   // filesystem path
	AST        *ast.File
	Token      *token.File
	Contents   []byte
	References map[ast.Node]*Node
}

type Node

type Node struct {
	Type NodeType
	// If Type == RPCDefNode or RPCCallNode,
	// RPC is the RPC being defined or called.
	RPC *RPC

	// If Type == SQLDBNode or RLogNode,
	// Func is the func name being called.
	Func string

	// Resource this refers to, if any
	Res Resource
}

type NodeType

type NodeType int
const (
	RPCDefNode NodeType = iota + 1
	RPCRefNode
	SQLDBNode
	RLogNode
	SecretsNode
	CronJobNode
	PubSubTopicDefNode
	PubSubPublisherNode
	PubSubSubscriberNode
)

type Package

type Package struct {
	AST        *ast.Package
	Name       string
	Doc        string
	ImportPath string // import path
	RelPath    string // import path relative to app root
	Dir        string // filesystem path
	Files      []*File
	Service    *Service // the service this package belongs to, if any
	Secrets    []string
	Resources  []Resource
}

type Param

type Param struct {
	IsPtr bool
	Type  *schema.Type
}

type PubSubGuarantee added in v1.3.0

type PubSubGuarantee int
const (
	AtLeastOnce PubSubGuarantee = iota
	ExactlyOnce
)

type PubSubPublisher added in v1.3.0

type PubSubPublisher struct {
	DeclFile *File // The file the publisher is declared in
}

type PubSubSubscriber added in v1.3.0

type PubSubSubscriber struct {
	Name     string       // The unique name of the subscriber
	Topic    *PubSubTopic // The topic the subscriber is registered against
	CallSite ast.Node     // The AST node representing the creation of the subscriber
	Func     ast.Node     // The function that is the subscriber (either a *ast.FuncLit or a *ast.FuncDecl)
	FuncFile *File        // The file the subscriber function is declared in
	DeclFile *File        // The file that the subscriber is defined in
	IdentAST *ast.Ident   // The AST node representing the value this topic is bound against

	AckDeadline      time.Duration
	MessageRetention time.Duration
	MinRetryBackoff  time.Duration
	MaxRetryBackoff  time.Duration
	MaxRetries       int64 // number of attempts
}

func (*PubSubSubscriber) AllowOnlyParsedUsage added in v1.3.0

func (p *PubSubSubscriber) AllowOnlyParsedUsage() bool

func (*PubSubSubscriber) File added in v1.3.0

func (p *PubSubSubscriber) File() *File

func (*PubSubSubscriber) Ident added in v1.3.0

func (p *PubSubSubscriber) Ident() *ast.Ident

func (*PubSubSubscriber) NodeType added in v1.3.0

func (p *PubSubSubscriber) NodeType() NodeType

func (*PubSubSubscriber) Type added in v1.3.0

func (p *PubSubSubscriber) Type() ResourceType

type PubSubTopic added in v1.3.0

type PubSubTopic struct {
	Name              string          // The unique name of the pub sub topic
	Doc               string          // The documentation on the pub sub topic
	DeliveryGuarantee PubSubGuarantee // What guarantees does the pub sub topic have?
	OrderingKey       string          // What field in the message type should be used to ensure First-In-First-Out (FIFO) for messages with the same key
	DeclFile          *File           // What file the topic is declared in
	MessageType       *Param          // The message type of the pub sub topic
	IdentAST          *ast.Ident      // The AST node representing the value this topic is bound against

	Subscribers []*PubSubSubscriber
	Publishers  []*PubSubPublisher
}

func (*PubSubTopic) AllowOnlyParsedUsage added in v1.3.0

func (p *PubSubTopic) AllowOnlyParsedUsage() bool

func (*PubSubTopic) File added in v1.3.0

func (p *PubSubTopic) File() *File

func (*PubSubTopic) Ident added in v1.3.0

func (p *PubSubTopic) Ident() *ast.Ident

func (*PubSubTopic) NodeType added in v1.3.0

func (p *PubSubTopic) NodeType() NodeType

func (*PubSubTopic) Type added in v1.3.0

func (p *PubSubTopic) Type() ResourceType

type RPC

type RPC struct {
	Svc         *Service
	Name        string
	Doc         string
	Func        *ast.FuncDecl
	File        *File
	Access      AccessType
	Raw         bool
	Path        *paths.Path
	HTTPMethods []string
	Request     *Param // request data; nil for Raw RPCs
	Response    *Param // response data; nil for Raw RPCs
}

type Resource added in v0.17.2

type Resource interface {
	Type() ResourceType
	File() *File
	Ident() *ast.Ident
	NodeType() NodeType
	AllowOnlyParsedUsage() bool // If true this resource can only be used with registered resource parsers. If false we allow any usage.
}

type ResourceType added in v0.17.2

type ResourceType int
const (
	SQLDBResource ResourceType = iota + 1
	CronJobResource
	PubSubTopicResource
	PubSubSubscriptionResource
)

func (ResourceType) String added in v0.17.2

func (i ResourceType) String() string

type SQLDB added in v0.17.2

type SQLDB struct {
	DeclFile *File
	DeclName *ast.Ident // where the resource is declared
	DBName   string
}

func (*SQLDB) AllowOnlyParsedUsage added in v1.3.0

func (r *SQLDB) AllowOnlyParsedUsage() bool

func (*SQLDB) File added in v0.17.2

func (r *SQLDB) File() *File

func (*SQLDB) Ident added in v0.17.2

func (r *SQLDB) Ident() *ast.Ident

func (*SQLDB) NodeType added in v1.3.0

func (r *SQLDB) NodeType() NodeType

func (*SQLDB) Type added in v0.17.2

func (r *SQLDB) Type() ResourceType

type Service

type Service struct {
	Name string
	Root *Package
	Pkgs []*Package
	RPCs []*RPC
}

A Service is a Go package that defines one or more RPCs. Its name is defined by the Go package name. A Service may not be a located in a child directory of another service.

Jump to

Keyboard shortcuts

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