spec

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Add    Action = "add"
	Delete Action = "delete"

	Routes      Resource = "route"
	Services    Resource = "service"
	Namespaces  Resource = "namespace"
	Modules     Resource = "module"
	Domains     Resource = "domain"
	Collections Resource = "collection"
	Documents   Resource = "document"
)

Variables

View Source
var DefaultNamespace = &Namespace{
	Name: "default",
	Tags: []string{"default"},
}

Functions

func ErrCollectionNotFound

func ErrCollectionNotFound(col string) error

func ErrDocumentNotFound

func ErrDocumentNotFound(doc string) error

func ErrDomainNotFound

func ErrDomainNotFound(domain string) error

func ErrModuleNotFound

func ErrModuleNotFound(mod string) error

func ErrNamespaceNotFound

func ErrNamespaceNotFound(ns string) error

func ErrRouteNotFound

func ErrRouteNotFound(route string) error

func ErrServiceNotFound

func ErrServiceNotFound(svc string) error

Types

type Action

type Action string

func (Action) String

func (act Action) String() string

type ChangeLog

type ChangeLog struct {
	ID        string  `json:"id"`
	Cmd       Command `json:"cmd"`
	Name      string  `json:"name"`
	Namespace string  `json:"namespace"`
	Item      any     `json:"item"`
	Version   int     `json:"version"`
	// contains filtered or unexported fields
}

func NewChangeLog

func NewChangeLog(item Named, namespace string, cmd Command) *ChangeLog

func (*ChangeLog) PushError

func (cl *ChangeLog) PushError(err error)

func (*ChangeLog) SetErrorChan

func (cl *ChangeLog) SetErrorChan(errChan chan error)

type Collection

type Collection struct {
	Name          string               `json:"name" koanf:"name"`
	NamespaceName string               `json:"namespace" koanf:"namespace"`
	Schema        any                  `json:"schema" koanf:"schema"`
	Type          CollectionType       `json:"type" koanf:"type"`
	Visibility    CollectionVisibility `json:"visibility" koanf:"visibility"`
	// Modules       []string             `json:"modules,omitempty" koanf:"modules"`
	Tags []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateCollection

func TransformDGateCollection(col *DGateCollection) *Collection

func TransformDGateCollections

func TransformDGateCollections(collections ...*DGateCollection) []*Collection

func (*Collection) GetName

func (n *Collection) GetName() string

type CollectionType

type CollectionType string
const (
	CollectionTypeDocument CollectionType = "document"
	CollectionTypeFetcher  CollectionType = "fetcher"
)

type CollectionVisibility

type CollectionVisibility string
const (
	CollectionVisibilityPublic  CollectionVisibility = "public"
	CollectionVisibilityPrivate CollectionVisibility = "private"
)

type Command

type Command string
var (
	AddRouteCommand         Command = newCommand(Add, Routes)
	AddServiceCommand       Command = newCommand(Add, Services)
	AddNamespaceCommand     Command = newCommand(Add, Namespaces)
	AddModuleCommand        Command = newCommand(Add, Modules)
	AddDomainCommand        Command = newCommand(Add, Domains)
	AddCollectionCommand    Command = newCommand(Add, Collections)
	AddDocumentCommand      Command = newCommand(Add, Documents)
	DeleteRouteCommand      Command = newCommand(Delete, Routes)
	DeleteServiceCommand    Command = newCommand(Delete, Services)
	DeleteNamespaceCommand  Command = newCommand(Delete, Namespaces)
	DeleteModuleCommand     Command = newCommand(Delete, Modules)
	DeleteDomainCommand     Command = newCommand(Delete, Domains)
	DeleteCollectionCommand Command = newCommand(Delete, Collections)
	DeleteDocumentCommand   Command = newCommand(Delete, Documents)
	NoopCommand             Command = Command("noop")
)

func (Command) Action

func (clc Command) Action() Action

func (Command) IsNoop

func (clc Command) IsNoop() bool

func (Command) Resource

func (clc Command) Resource() Resource

func (Command) String

func (clc Command) String() string

type DGateCollection

type DGateCollection struct {
	Name          string               `json:"name"`
	Namespace     *DGateNamespace      `json:"namespace"`
	Schema        *jsonschema.Schema   `json:"schema"`
	SchemaPayload string               `json:"schema_payload"`
	Type          CollectionType       `json:"type"`
	Visibility    CollectionVisibility `json:"visibility"`
	// Modules       []*DGateModule       `json:"modules"`
	Tags []string `json:"tags,omitempty"`
}

func TransformCollection

func TransformCollection(ns *DGateNamespace, mods []*DGateModule, col *Collection) *DGateCollection

func TransformCollections

func TransformCollections(ns *DGateNamespace, mods []*DGateModule, collections ...*Collection) []*DGateCollection

func (*DGateCollection) GetName

func (n *DGateCollection) GetName() string

type DGateDocument

type DGateDocument struct {
	ID         string           `json:"id"`
	CreatedAt  time.Time        `json:"created_at"`
	UpdatedAt  time.Time        `json:"updated_at"`
	Namespace  *DGateNamespace  `json:"namespace"`
	Collection *DGateCollection `json:"collection"`
	Data       string           `json:"data"`
}

func TransformDocument

func TransformDocument(ns *DGateNamespace, col *DGateCollection, document *Document) *DGateDocument

func TransformDocuments

func TransformDocuments(ns *DGateNamespace, col *DGateCollection, documents ...*Document) []*DGateDocument

func (*DGateDocument) GetName

func (n *DGateDocument) GetName() string

type DGateDomain

type DGateDomain struct {
	Name      string           `json:"name"`
	Namespace *DGateNamespace  `json:"namespace"`
	Patterns  []string         `json:"pattern"`
	TLSCert   *tls.Certificate `json:"tls_config"`
	Priority  int              `json:"priority"`
	Cert      string           `json:"cert"`
	Key       string           `json:"key"`
	Tags      []string         `json:"tags,omitempty"`
}

func TransformDomain

func TransformDomain(ns *DGateNamespace, dom *Domain) *DGateDomain

func TransformDomains

func TransformDomains(ns *DGateNamespace, domains ...*Domain) []*DGateDomain

type DGateModule

type DGateModule struct {
	Name        string          `json:"name"`
	Namespace   *DGateNamespace `json:"namespace"`
	Payload     string          `json:"payload"`
	Type        ModuleType      `json:"module_type"`
	Permissions []string        `json:"permissions,omitempty"`
	Tags        []string        `json:"tags,omitempty"`
}

func TransformModule

func TransformModule(ns *DGateNamespace, m *Module) (*DGateModule, error)

func TransformModules

func TransformModules(ns *DGateNamespace, modules ...*Module) ([]*DGateModule, error)

func (*DGateModule) GetName

func (m *DGateModule) GetName() string

type DGateNamespace

type DGateNamespace struct {
	Name string   `json:"name"`
	Tags []string `json:"tags,omitempty"`
}

func TransformNamespace

func TransformNamespace(ns *Namespace) *DGateNamespace

func TransformNamespaces

func TransformNamespaces(namespaces ...*Namespace) []*DGateNamespace

func (*DGateNamespace) GetName

func (ns *DGateNamespace) GetName() string

type DGateRoute

type DGateRoute struct {
	Name         string          `json:"name"`
	Paths        []string        `json:"paths"`
	Methods      []string        `json:"methods"`
	StripPath    bool            `json:"stripPath"`
	PreserveHost bool            `json:"preserveHost"`
	Service      *DGateService   `json:"service"`
	Namespace    *DGateNamespace `json:"namespace"`
	Modules      []*DGateModule  `json:"modules"`
	Tags         []string        `json:"tags,omitempty"`
}

func TransformRoute

func TransformRoute(r Route) *DGateRoute

func TransformRoutes

func TransformRoutes(routes ...Route) []*DGateRoute

func (*DGateRoute) GetName

func (r *DGateRoute) GetName() string

type DGateService

type DGateService struct {
	Name      string          `json:"name"`
	URLs      []*url.URL      `json:"urls"`
	Tags      []string        `json:"tags,omitempty"`
	Namespace *DGateNamespace `json:"namespace"`

	DisableQueryParams bool          `json:"disableQueryParams,omitempty"`
	Retries            int           `json:"retries,omitempty"`
	RetryTimeout       time.Duration `json:"retryTimeout,omitempty"`
	ConnectTimeout     time.Duration `json:"connectTimeout,omitempty"`
	RequestTimeout     time.Duration `json:"requestTimeout,omitempty"`
	TLSSkipVerify      bool          `json:"tlsSkipVerify,omitempty"`
	HTTP2Only          bool          `json:"http2_only,omitempty"`
	HideDGateHeaders   bool          `json:"hideDGateHeaders,omitempty"`
}

func TransformService

func TransformService(ns *DGateNamespace, s *Service) *DGateService

func TransformServices

func TransformServices(ns *DGateNamespace, services ...*Service) []*DGateService

func (*DGateService) GetName

func (s *DGateService) GetName() string

type Document

type Document struct {
	ID             string    `json:"id"`
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
	NamespaceName  string    `json:"namespace"`
	CollectionName string    `json:"collection"`
	Data           any       `json:"data"`
}

func TransformDGateDocument

func TransformDGateDocument(document *DGateDocument) *Document

func TransformDGateDocuments

func TransformDGateDocuments(documents ...*DGateDocument) []*Document

func (*Document) GetName

func (n *Document) GetName() string

type Domain

type Domain struct {
	Name          string   `json:"name" koanf:"name"`
	NamespaceName string   `json:"namespace" koanf:"namespace"`
	Patterns      []string `json:"patterns" koanf:"patterns"`
	Priority      int      `json:"priority" koanf:"priority"`
	Cert          string   `json:"cert" koanf:"cert"`
	Key           string   `json:"key" koanf:"key"`
	Tags          []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateDomain

func TransformDGateDomain(dom *DGateDomain) *Domain

func TransformDGateDomains

func TransformDGateDomains(domains ...*DGateDomain) []*Domain

func (*Domain) GetName

func (n *Domain) GetName() string

type Module

type Module struct {
	Name          string     `json:"name" koanf:"name"`
	NamespaceName string     `json:"namespace" koanf:"namespace"`
	Payload       string     `json:"payload" koanf:"payload"`
	Type          ModuleType `json:"moduleType,omitempty" koanf:"moduleType"`
	Permissions   []string   `json:"permissions,omitempty" koanf:"permissions"`
	Tags          []string   `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateModule

func TransformDGateModule(m *DGateModule) *Module

func TransformDGateModules

func TransformDGateModules(modules ...*DGateModule) []*Module

func (*Module) GetName

func (m *Module) GetName() string

type ModuleType

type ModuleType string
const (
	ModuleTypeJavascript ModuleType = "javascript"
	ModuleTypeTypescript ModuleType = "typescript"
)

func (ModuleType) String

func (m ModuleType) String() string

func (ModuleType) Valid

func (m ModuleType) Valid() bool

type Name

type Name string

type Named

type Named interface {
	GetName() string
}

type Namespace

type Namespace struct {
	Name string   `json:"name" koanf:"name"`
	Tags []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateNamespace

func TransformDGateNamespace(ns *DGateNamespace) *Namespace

func TransformDGateNamespaces

func TransformDGateNamespaces(namespaces ...*DGateNamespace) []*Namespace

func (*Namespace) GetName

func (n *Namespace) GetName() string

type RFC3339Time

type RFC3339Time time.Time

func (RFC3339Time) MarshalJSON

func (t RFC3339Time) MarshalJSON() ([]byte, error)

func (*RFC3339Time) UnmarshalJSON

func (t *RFC3339Time) UnmarshalJSON(data []byte) error

type Resource

type Resource string

func (Resource) IsRelatedTo

func (resource1 Resource) IsRelatedTo(resource2 Resource) bool

func (Resource) String

func (rt Resource) String() string

type ResponseWriterTracker

type ResponseWriterTracker interface {
	http.ResponseWriter
	Status() int
	HeadersSent() bool
	BytesWritten() int64
}

func NewResponseWriterTracker

func NewResponseWriterTracker(rw http.ResponseWriter) ResponseWriterTracker

type Route

type Route struct {
	Name          string   `json:"name" koanf:"name"`
	Paths         []string `json:"paths" koanf:"paths"`
	Methods       []string `json:"methods" koanf:"methods"`
	Schemes       []string `json:"schemes,omitempty" koanf:"schemes"`
	PreserveHost  bool     `json:"preserveHost" koanf:"preserveHost"`
	StripPath     bool     `json:"stripPath" koanf:"stripPath"`
	ServiceName   string   `json:"service,omitempty" koanf:"service"`
	NamespaceName string   `json:"namespace" koanf:"namespace"`
	Modules       []string `json:"modules,omitempty" koanf:"modules"`
	Tags          []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateRoute

func TransformDGateRoute(r *DGateRoute) *Route

func TransformDGateRoutes

func TransformDGateRoutes(routes ...*DGateRoute) []*Route

func (*Route) GetName

func (m *Route) GetName() string

type Service

type Service struct {
	Name               string         `json:"name" koanf:"name"`
	URLs               []string       `json:"urls" koanf:"urls"`
	NamespaceName      string         `json:"namespace" koanf:"namespace"`
	Retries            *int           `json:"retries,omitempty" koanf:"retries"`
	RetryTimeout       *time.Duration `json:"retryTimeout,omitempty" koanf:"retryTimeout"`
	ConnectTimeout     *time.Duration `json:"connectTimeout,omitempty"  koanf:"connectTimeout"`
	RequestTimeout     *time.Duration `json:"requestTimeout,omitempty"  koanf:"requestTimeout"`
	TLSSkipVerify      *bool          `json:"tlsSkipVerify,omitempty" koanf:"tlsSkipVerify"`
	HTTP2Only          *bool          `json:"http2Only,omitempty" koanf:"http2Only"`
	HideDGateHeaders   *bool          `json:"hideDGateHeaders,omitempty" koanf:"hideDGateHeaders"`
	DisableQueryParams *bool          `json:"disableQueryParams,omitempty" koanf:"disableQueryParams"`
	Tags               []string       `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateService

func TransformDGateService(s *DGateService) *Service

func TransformDGateServices

func TransformDGateServices(services ...*DGateService) []*Service

func (*Service) GetName

func (s *Service) GetName() string

Jump to

Keyboard shortcuts

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