web_feature

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectTypeFeature  caskin.ObjectType = "feature"
	ObjectTypeFrontend caskin.ObjectType = "frontend"
	ObjectTypeBackend  caskin.ObjectType = "backend"
)

Variables

View Source
var (
	DefaultSuperRootName              = "github.com/awatercolorpen/caskin/web_feature"
	DefaultFeatureRootName            = "feature-root"
	DefaultFeatureRootDescription     = "root node of feature object"
	DefaultFeatureRootGroup           = ""
	DefaultFrontendRootKey            = "frontend-root"
	DefaultFrontendRootType           = FrontendTypeNil
	DefaultFrontendRootDescription    = "root node of frontend object"
	DefaultFrontendRootGroup          = ""
	DefaultBackendRootPath            = "backend-root"
	DefaultBackendRootMethod          = ""
	DefaultBackendRootDescription     = "root node of backend object"
	DefaultBackendRootGroup           = ""
	DefaultWebFeatureVersionTableName = "caskin_web_feature_versions"
)
View Source
var (
	// local cache for
	LocalCache = cache.New(2*time.Minute, 5*time.Minute)
)

Functions

func BackendFactory

func BackendFactory() caskin.CustomizedData

func FeatureFactory

func FeatureFactory() caskin.CustomizedData

func FrontendFactory

func FrontendFactory() caskin.CustomizedData

func GetBackendRootObject

func GetBackendRootObject() caskin.Object

func GetFeatureRootObject

func GetFeatureRootObject() caskin.Object

func GetFrontendRootObject

func GetFrontendRootObject() caskin.Object

func ManualCreateRootObject

func ManualCreateRootObject(db caskin.MetaDB, factory caskin.ObjectFactory, domain caskin.Domain) (err error)

func TopSort

func TopSort(tree Relations) []uint64

TopSort root first

Types

type Backend

type Backend struct {
	Path        string `json:"path"`
	Method      string `json:"method"`
	Description string `json:"description"`
	Group       string `json:"group"`
}

Backend

func (*Backend) GetName

func (b *Backend) GetName() string

func (*Backend) GetObjectType

func (b *Backend) GetObjectType() caskin.ObjectType

func (*Backend) JSONQuery

func (b *Backend) JSONQuery() []*datatypes.JSONQueryExpression

type CasbinStruct

type CasbinStruct struct {
	M  string     `json:"m"`
	P  [][]string `json:"p"`
	G  [][]string `json:"g"`
	G2 [][]string `json:"g2"`
}

type Dump

type Dump struct {
	Feature         []*caskin.CustomizedDataPair `json:"feature"`
	Frontend        []*caskin.CustomizedDataPair `json:"frontend"`
	Backend         []*caskin.CustomizedDataPair `json:"backend"`
	FeatureTree     Relations                    `json:"feature_tree"`
	FrontendTree    Relations                    `json:"frontend_tree"`
	BackendTree     Relations                    `json:"backend_tree"`
	FeatureRelation Relations                    `json:"feature_relation"`
}

func NewDump

func NewDump(feature, frontend, backend []*caskin.CustomizedDataPair, relations Relations) *Dump

func (*Dump) InitFeatureRelationMap

func (d *Dump) InitFeatureRelationMap(relations Relations) Relations

func (*Dump) InitSingleFeatureRelation

func (d *Dump) InitSingleFeatureRelation(relation Relation) Relation

func (*Dump) ToRelation

func (d *Dump) ToRelation() *DumpRelation

type DumpFileStruct

type DumpFileStruct struct {
	Feature                     []*Feature  `json:"feature"`
	Frontend                    []*Frontend `json:"frontend"`
	Backend                     []*Backend  `json:"backend"`
	VirtualIndexFeatureTree     Relations   `json:"virtual_index_feature_tree"`
	VirtualIndexFrontendTree    Relations   `json:"virtual_index_frontend_tree"`
	VirtualIndexBackendTree     Relations   `json:"virtual_index_backend_tree"`
	VirtualIndexFeatureRelation Relations   `json:"virtual_index_feature_relation"`
}

func (*DumpFileStruct) ExportToFile

func (d *DumpFileStruct) ExportToFile(name string) error

func (*DumpFileStruct) ExportToWebFeature

func (d *DumpFileStruct) ExportToWebFeature(w *WebFeature) error

func (*DumpFileStruct) ImportFromDump

func (d *DumpFileStruct) ImportFromDump(dump *Dump) error

func (*DumpFileStruct) ImportFromFile

func (d *DumpFileStruct) ImportFromFile(name string) error

func (*DumpFileStruct) IsValid

func (d *DumpFileStruct) IsValid() error

type DumpRelation

type DumpRelation struct {
	FeatureTree     Relations `json:"feature_tree"`
	FrontendTree    Relations `json:"frontend_tree"`
	BackendTree     Relations `json:"backend_tree"`
	FeatureRelation Relations `json:"feature_relation"`
}

func (*DumpRelation) MergedRelation

func (d *DumpRelation) MergedRelation() Relations

func (*DumpRelation) Scan

func (d *DumpRelation) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (DumpRelation) Value

func (d DumpRelation) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

func (*DumpRelation) Version

func (d *DumpRelation) Version() string

type Executor

type Executor struct {
	FeatureRootObject func() caskin.Object
	// contains filtered or unexported fields
}

func (*Executor) AuthBackendAPIEnforce

func (e *Executor) AuthBackendAPIEnforce(backend *Backend) error

func (*Executor) AuthFrontend

func (e *Executor) AuthFrontend() []*Frontend

func (*Executor) AuthFrontendCaskinStruct

func (e *Executor) AuthFrontendCaskinStruct(subject string) (*CasbinStruct, error)

func (*Executor) BuildVersion

func (e *Executor) BuildVersion() error

func (*Executor) CreateBackend

func (e *Executor) CreateBackend(backend *Backend, object caskin.Object) error

func (*Executor) CreateFeature

func (e *Executor) CreateFeature(feature *Feature, object caskin.Object) error

func (*Executor) CreateFrontend

func (e *Executor) CreateFrontend(frontend *Frontend, object caskin.Object) error

func (*Executor) DeleteBackend

func (e *Executor) DeleteBackend(object caskin.Object) error

func (*Executor) DeleteFeature

func (e *Executor) DeleteFeature(object caskin.Object) error

func (*Executor) DeleteFrontend

func (e *Executor) DeleteFrontend(object caskin.Object) error

func (*Executor) Dump

func (e *Executor) Dump() (*Dump, error)

func (*Executor) GetBackend

func (e *Executor) GetBackend() ([]*caskin.CustomizedDataPair, error)

func (*Executor) GetFeature

func (e *Executor) GetFeature() ([]*caskin.CustomizedDataPair, error)

func (*Executor) GetFeatureRelation

func (e *Executor) GetFeatureRelation() (Relations, error)

GetFeatureRelation 1. get all feature to backend and frontend 's relations, not inheritance relations

func (*Executor) GetFeatureRelationByFeature

func (e *Executor) GetFeatureRelationByFeature(object caskin.Object) (Relation, error)

GetFeatureRelationByFeature 1. get one feature to backend and frontend 's relation, not inheritance relation

func (*Executor) GetFrontend

func (e *Executor) GetFrontend() ([]*caskin.CustomizedDataPair, error)

func (*Executor) GetLatestVersion

func (e *Executor) GetLatestVersion() (*WebFeatureVersion, error)

func (*Executor) GetVersion

func (e *Executor) GetVersion() ([]*WebFeatureVersion, error)

func (*Executor) ModifyFeatureRelationPerFeature

func (e *Executor) ModifyFeatureRelationPerFeature(object caskin.Object, relation Relation) error

ModifyFeatureRelationPerFeature 1. modify one feature to backend and frontend 's relation, not inheritance relation

func (*Executor) NormalDomainGetFeatureObject

func (e *Executor) NormalDomainGetFeatureObject() ([]caskin.Object, error)

func (*Executor) NormalDomainGetPolicyList

func (e *Executor) NormalDomainGetPolicyList() ([]*caskin.Policy, error)

func (*Executor) NormalDomainGetPolicyListByRole

func (e *Executor) NormalDomainGetPolicyListByRole(role caskin.Role) ([]*caskin.Policy, error)

func (*Executor) NormalDomainModifyPolicyListPerRole

func (e *Executor) NormalDomainModifyPolicyListPerRole(role caskin.Role, input []*caskin.Policy) error

func (*Executor) RecoverBackend

func (e *Executor) RecoverBackend(backend *Backend, object caskin.Object) error

func (*Executor) RecoverFeature

func (e *Executor) RecoverFeature(feature *Feature, object caskin.Object) error

func (*Executor) RecoverFrontend

func (e *Executor) RecoverFrontend(frontend *Frontend, object caskin.Object) error

func (*Executor) SyncLatestVersionToAllDomain

func (e *Executor) SyncLatestVersionToAllDomain() error

func (*Executor) SyncVersionToAllDomain

func (e *Executor) SyncVersionToAllDomain(version *WebFeatureVersion) error

func (*Executor) SyncVersionToOneDomain

func (e *Executor) SyncVersionToOneDomain(version *WebFeatureVersion, domain caskin.Domain) error

func (*Executor) UpdateBackend

func (e *Executor) UpdateBackend(backend *Backend, object caskin.Object) error

func (*Executor) UpdateFeature

func (e *Executor) UpdateFeature(feature *Feature, object caskin.Object) error

func (*Executor) UpdateFrontend

func (e *Executor) UpdateFrontend(frontend *Frontend, object caskin.Object) error

type Feature

type Feature struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Group       string `json:"group"`
}

Feature

func (*Feature) GetName

func (f *Feature) GetName() string

func (*Feature) GetObjectType

func (f *Feature) GetObjectType() caskin.ObjectType

func (*Feature) JSONQuery

func (f *Feature) JSONQuery() []*datatypes.JSONQueryExpression

type Frontend

type Frontend struct {
	Key         string       `json:"key"`
	Type        FrontendType `json:"type"`
	Description string       `json:"description"`
	Group       string       `json:"group"`
}

Frontend

func (*Frontend) GetName

func (f *Frontend) GetName() string

func (*Frontend) GetObjectType

func (f *Frontend) GetObjectType() caskin.ObjectType

func (*Frontend) JSONQuery

func (f *Frontend) JSONQuery() []*datatypes.JSONQueryExpression

type FrontendType

type FrontendType string
const (
	FrontendTypeNil         FrontendType = ""
	FrontendTypeMenu        FrontendType = "menu"
	FrontendTypeSubFunction FrontendType = "sub_function"
)

type Options

type Options struct {
	DisableCache bool          `json:"disable_cache"`
	Domain       caskin.Domain `json:"domain"`
}

Options configuration for web_feature

type Relation

type Relation = caskin.InheritanceRelation

type Relations

type Relations = caskin.InheritanceRelations

type VersionedDomain

type VersionedDomain interface {
	caskin.Domain
	GetVersion() string
	SetVersion(string)
}

type WebFeature

type WebFeature struct {
	// contains filtered or unexported fields
}

func New

func New(c *caskin.Caskin, options *Options) (w *WebFeature, err error)

func (*WebFeature) GetExecutor

func (w *WebFeature) GetExecutor(provider caskin.CurrentProvider) *Executor

type WebFeatureVersion

type WebFeatureVersion struct {
	ID        uint64         `gorm:"column:id;primaryKey"   json:"id,omitempty"`
	CreatedAt time.Time      `gorm:"column:created_at"      json:"created_at,omitempty"`
	UpdatedAt time.Time      `gorm:"column:updated_at"      json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"column:delete_at;index" json:"-"`
	SHA256    string         `gorm:"column:sha256;unique"   json:"sha256,omitempty"`
	MetaData  *DumpRelation  `gorm:"column:metadata"        json:"metadata,omitempty"`
}

func (*WebFeatureVersion) IsCompatible

func (w *WebFeatureVersion) IsCompatible(dump *Dump) error

func (*WebFeatureVersion) TableName

func (w *WebFeatureVersion) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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