apiservice

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0, AGPL-3.0 Imports: 41 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConvertRowTestCase1Data = `` /* 509534-byte string literal not displayed */
View Source
var ConvertRowTestCase2Data = `` /* 348025-byte string literal not displayed */

Functions

This section is empty.

Types

type Action

type Action string
const (
	PERSIST_ACTION_NONE   Action = "None"   // Фиктивная пустая action
	PERSIST_ACTION_GET    Action = "Get"    // Запрос одного объекта
	PERSIST_ACTION_CREATE Action = "Create" // Создание объекта
	PERSIST_ACTION_UPDATE Action = "Update" // Обновление объекта
	PERSIST_ACTION_DELETE Action = "Delete" // Удаление объекта
	PERSIST_ACTION_MERGE  Action = "Merge"  // Слияние объекта
)

type Config

type Config struct {
	EntityConfigFile     string            `yaml:"entity_config_file" json:"entity_config_file"`
	PopulateCacheOnStart bool              `yaml:"populate_cache_on_start" json:"populate_cache_on_start"`
	QueryOption          QueryOptionConfig `yaml:"query_option" json:"query_option"`
	EntityConfig         EntityConfig      `yaml:"entity_config" json:"entity_config"`
	Meta                 *_meta.Meta       `yaml:"meta" json:"meta"`
}

Config конфигурационные настройки

type EntityConfig

type EntityConfig struct {
	EntityDirName string             `yaml:"source_dir" json:"source_dir"`
	Definition    []_meta.Definition `yaml:"definition,omitempty" json:"definition,omitempty" xml:"definition,omitempty"` // Определение сущностей
}

EntityConfig конфигурационные настройки сущностей

type OptionsCache

type OptionsCache map[string]*_meta.Options

type QueryOptionConfig

type QueryOptionConfig struct {
	DelimiterStart         string `yaml:"delimiter_start" json:"delimiter_start"`                     // [ разделить начало для определения спец параметров
	DelimiterEnd           string `yaml:"delimiter_end" json:"delimiter_end"`                         // ] разделить конец для определения спец параметров
	FromEntity             string `yaml:"from_entity" json:"from_entity"`                             // [from_entity] имя входной сущности
	Fields                 string `yaml:"fields" json:"fields"`                                       // [fields] фильтрация список полей в ответе
	SkipCache              string `yaml:"skip_cache" json:"skip_cache"`                               // [skip_cache] принудительно считать из внешнего источника
	SkipCalculation        string `yaml:"skip_calculation" json:"skip_calculation"`                   // [skip_calculation] принудительно отключить все вычисления
	UseCache               string `yaml:"use_cache" json:"use_cache"`                                 // [use_cache] принудительно использовать кеширование - имеет приоритет над skip_cache
	EmbedError             string `yaml:"embed_error" json:"embed_error"`                             // [embed_error] встраивать отдельные типы некритичных ошибок в текст ответа
	CascadeUp              string `yaml:"cascade_up" json:"cascade_up"`                               // [cascade_up] сколько уровней вверх по FK
	CascadeDown            string `yaml:"cascade_down" json:"cascade_down"`                           // [cascade_down] сколько уровней вниз по FK
	TxExternal             string `yaml:"tx" json:"tx"`                                               // [tx] идентификатор внешней транзакции
	IgnoreExtraField       string `yaml:"ignore_extra_field" json:"ignore_extra_field"`               // [ignore_extra_field] игнорировать лишние поля в параметрах запроса
	NameFormat             string `yaml:"name_format" json:"name_format"`                             // [name_format] формат именования полей в параметрах запроса 'json', 'yaml', 'xml', 'xsl', 'name'
	OutFormat              string `yaml:"out_format" json:"out_format"`                               // [out_format] формат вывода результата 'json', 'yaml', 'xml', 'xsl'
	OutTrace               string `yaml:"out_trace" json:"out_trace"`                                 // [out_trace] вывод трассировки
	Validate               string `yaml:"validate" json:"validate"`                                   // [validate] проверка данных
	MultiRow               string `yaml:"multi_row" json:"multi_row"`                                 // [multi_row] признак многострочной обработки
	Filter                 string `yaml:"filter" json:"filter"`                                       // [filter] признак  фильтрации
	StaticFiltering        string `yaml:"static_filtering" json:"static_filtering"`                   // [static_filtering] признак статической фильтрации
	Persist                string `yaml:"persist" json:"persist"`                                     // [persist] признак, что отправлять данные в хранилище
	DbOrder                string `yaml:"db_order" json:"db_order"`                                   // [db_order] последовательность сортировки строк в ответе
	DbWhere                string `yaml:"db_where" json:"db_where"`                                   // [db_where] фраза where для встраивания в запрос
	DbLimit                string `yaml:"db_limit" json:"db_limit"`                                   // [db_limit] ограничение на выборку данных в запросе
	DbOffset               string `yaml:"db_offset" json:"db_offset"`                                 // [db_offset] сдвиг строки, с которой начать выводить данные в запросе
	PersistRestrictFields  string `yaml:"persist_restrict_fields" json:"persist_restrict_fields"`     // [persist_restrict_fields] ограничить поля сохранения, теми, что пришли на вход в Marshal
	PersistUseUK           string `yaml:"persist_use_uk" json:"persist_use_uk"`                       // [persist_use_uk] для сохранения использовать UK, если не заполнен PK
	PersistUpdateAllFields string `yaml:"persist_update_all_fields" json:"persist_update_all_fields"` // [persist_update_all_fields] обновлять все поля объекта

	DelimiterStartFilter       string `yaml:"-" json:"-"`
	DelimiterStartFull         string `yaml:"-" json:"-"`
	DelimiterEndFull           string `yaml:"-" json:"-"`
	FromEntityFull             string `yaml:"-" json:"-"`
	FieldsFull                 string `yaml:"-" json:"-"`
	SkipCacheFull              string `yaml:"-" json:"-"`
	SkipCalculationFull        string `yaml:"-" json:"-"`
	UseCacheFull               string `yaml:"-" json:"-"`
	EmbedErrorFull             string `yaml:"-" json:"-"`
	CascadeUpFull              string `yaml:"-" json:"-"`
	CascadeDownFull            string `yaml:"-" json:"-"`
	TxExternalFull             string `yaml:"-" json:"-"`
	IgnoreExtraFieldFull       string `yaml:"-" json:"-"`
	NameFormatFull             string `yaml:"-" json:"-"`
	OutFormatFull              string `yaml:"-" json:"-"`
	OutTraceFull               string `yaml:"-" json:"-"`
	ValidateFull               string `yaml:"-" json:"-"`
	MultiRowFull               string `yaml:"-" json:"-"`
	FilterFull                 string `yaml:"-" json:"-"`
	StaticFilteringFull        string `yaml:"-" json:"-"`
	PersistFull                string `yaml:"-" json:"-"`
	DbOrderFull                string `yaml:"-" json:"-"`
	DbWhereFull                string `yaml:"-" json:"-"`
	DbLimitFull                string `yaml:"-" json:"-"`
	DbOffsetFull               string `yaml:"-" json:"-"`
	PersistRestrictFieldsFull  string `yaml:"-" json:"-"`
	PersistUseUKFull           string `yaml:"-" json:"-"`
	PersistUpdateAllFieldsFull string `yaml:"-" json:"-"`
}

type Service

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

Service represent API service

func New

func New(ctx context.Context, errCh chan<- error, cfg *Config, storageMap map[string]_storage.Service, cache _cache.CacheService, gMeta *_meta.Meta) (*Service, error)

New returns a new Service

func (*Service) ConvertMarshal

func (s *Service) ConvertMarshal(ctx context.Context, entityName string, inBuf []byte, inFormat string, queryOptions _meta.QueryOptions) (outBuf []byte, outFormat string, err error)

ConvertMarshal преобразовать между сущностями

func (*Service) CreateEntityMeta

func (s *Service) CreateEntityMeta(ctx context.Context, inBuf []byte, format string) (result bool, outBuf []byte, err error)

CreateEntityMeta создать метаданные entity

func (*Service) GetEntity

func (s *Service) GetEntity(entityName string) *_meta.Entity

func (*Service) GetEntityMeta

func (s *Service) GetEntityMeta(ctx context.Context, entityName, format string) (exists bool, outBuf []byte, myerr error)

GetEntityMeta извлечь метаданные entity

func (*Service) GetEntityUnsafe added in v0.3.3

func (s *Service) GetEntityUnsafe(entityName string) *_meta.Entity

func (*Service) GetMarshal

func (s *Service) GetMarshal(ctx context.Context, entityName string, inFormat string, queryOptions _meta.QueryOptions, keyArgs ...interface{}) (exists bool, outBuf []byte, outFormat string, err error, errors _err.Errors)

GetMarshal извлечь данные и преобразовать в JSON / XML / YAML / XLS

func (*Service) GetOptionFromCache

func (s *Service) GetOptionFromCache(ctx context.Context, key string) *_meta.Options

func (*Service) GetSingle added in v0.3.3

func (s *Service) GetSingle(ctx context.Context, requestID uint64, entity *_meta.Entity, options *_meta.Options, cascadeUp int, cascadeDown int, key *_meta.Key, keyArgs ...interface{}) (exists bool, rowOut *_meta.Object, err error, errors _err.Errors)

GetSingle извлечь данные в struct - только запрошенные поля

func (*Service) GetSingleByKeyUnsafe added in v0.3.3

func (s *Service) GetSingleByKeyUnsafe(ctx context.Context, requestID uint64, entity *_meta.Entity, options *_meta.Options, rowIn *_meta.Object, key *_meta.Key) (exists bool, rowOut *_meta.Object, keyArgs []interface{}, err error, errors _err.Errors)

GetSingleByKeyUnsafe считать поля ключа

func (*Service) GetSingleUnsafe added in v0.3.3

func (s *Service) GetSingleUnsafe(ctx context.Context, requestID uint64, entity *_meta.Entity, options *_meta.Options, cascadeUp int, cascadeDown int, key *_meta.Key, keyArgs ...interface{}) (exists bool, rowOut *_meta.Object, err error, errors _err.Errors)

GetSingleUnsafe извлечь данные в struct - только запрошенные поля

func (*Service) InitValidator

func (s *Service) InitValidator() (err error)

func (*Service) MarshalEntity added in v0.3.3

func (s *Service) MarshalEntity(requestID uint64, val any, operation, name string, format string) (buf []byte, myerr error)

MarshalEntity трансформировать произвольную структуру в 'json', 'yaml', 'xml', 'xls'

func (*Service) MarshalMap added in v0.3.3

func (s *Service) MarshalMap(requestID uint64, entity *_meta.Entity, options *_meta.Options, rowInI interface{}, restrictOutFields bool, addRefFields bool, addUKFields bool) (rowOut *_meta.Object, err error)

MarshalMap - сформировать Object из map[string]interface{}

func (*Service) MarshalXls

func (s *Service) MarshalXls(requestID uint64, val any, name string, inFile multipart.File) (buf []byte, myerr error)

MarshalXls трансформировать произвольную структуру в 'xls'

func (*Service) NewRowAll added in v0.3.3

func (s *Service) NewRowAll(requestID uint64, entity *_meta.Entity, options *_meta.Options) (row *_meta.Object, err error)

func (*Service) NewSliceAll added in v0.3.3

func (s *Service) NewSliceAll(requestID uint64, entity *_meta.Entity, options *_meta.Options, len, cap int) (slice *_meta.Object, err error)

func (*Service) ParseQueryOptions added in v0.3.3

func (s *Service) ParseQueryOptions(ctx context.Context, requestID uint64, key string, entity *_meta.Entity, referenceField *_meta.Field, queryOptions _meta.QueryOptions, gopt *_meta.GlobalOptions) (opt *_meta.Options, err error)

func (*Service) PersistMarshal added in v0.3.3

func (s *Service) PersistMarshal(ctx context.Context, action Action, entityName string, inBuf []byte, inFormat string, queryOptions _meta.QueryOptions) (outBuf []byte, outFormat string, err error, errors _err.Errors)

PersistMarshal создать строку во внешнем сервисе

func (*Service) PersistMultiUnsafe added in v0.3.3

func (s *Service) PersistMultiUnsafe(ctx context.Context, requestID uint64, action Action, entity *_meta.Entity, options *_meta.Options, rowsInI []interface{}, cascadeUp int, cascadeDown int, useCache bool) (rowsOut *_meta.Object, err error, errors _err.Errors)

PersistMultiUnsafe сохранить строки во внешнем сервисе

func (*Service) PersistSingleUnsafe added in v0.3.3

func (s *Service) PersistSingleUnsafe(ctx context.Context, requestID uint64, action Action, entity *_meta.Entity, options *_meta.Options, rowInI interface{}, cascadeUp int, cascadeDown int, useCache bool) (rowOut *_meta.Object, err error, errors _err.Errors)

PersistSingleUnsafe создать строку во внешнем сервисе

func (*Service) PopulateAllEntityCache

func (s *Service) PopulateAllEntityCache(ctx context.Context) (err error)

func (*Service) PopulateEntityCache

func (s *Service) PopulateEntityCache(ctx context.Context, entity *_meta.Entity) (err error)

func (*Service) RegisterStorage

func (s *Service) RegisterStorage(name string, storage _storage.Service) (err error)

func (*Service) RegisterStorages

func (s *Service) RegisterStorages(storageMap map[string]_storage.Service) (err error)

func (*Service) Select

func (s *Service) Select(ctx context.Context, requestID uint64, entity *_meta.Entity, options *_meta.Options, cascadeUp int, cascadeDown int, key *_meta.Key, keyArgs ...interface{}) (exists bool, rowsOut *_meta.Object, err error, errors _err.Errors)

Select извлечь данные в slice - только запрошенные поля

func (*Service) SelectMarshal

func (s *Service) SelectMarshal(ctx context.Context, entityName string, inFormat string, queryOptions _meta.QueryOptions) (exists bool, outBuf []byte, outFormat string, err error, errors _err.Errors)

SelectMarshal извлечь данные и преобразовать в JSON / XML / YAML / XLS

func (*Service) SetOptionToCache

func (s *Service) SetOptionToCache(ctx context.Context, key string, options *_meta.Options)

func (*Service) Shutdown

func (s *Service) Shutdown() (err error)

Shutdown shutting down service

func (*Service) UnmarshalEntity added in v0.3.3

func (s *Service) UnmarshalEntity(requestID uint64, entity *_meta.Entity, buf []byte, val any, operation, name string, format string, multiRow bool) (err error)

UnmarshalEntity разобрать произвольную структуру из 'json', 'yaml', 'xml'

func (*Service) UnmarshalMultiInterface added in v0.3.3

func (s *Service) UnmarshalMultiInterface(requestID uint64, entity *_meta.Entity, inBuf []byte, inFormat string) (rowsI []interface{}, err error)

UnmarshalMultiInterface - распарсить много строк в []interface{}

func (*Service) UnmarshalMultiObject added in v0.3.3

func (s *Service) UnmarshalMultiObject(requestID uint64, entity *_meta.Entity, options *_meta.Options, inBuf []byte, inFormat string, ignoreExtra bool) (rows *_meta.Object, err error)

UnmarshalMultiObject - распарсить много строк в структуру

func (*Service) UnmarshalSingleInterface added in v0.3.3

func (s *Service) UnmarshalSingleInterface(requestID uint64, entity *_meta.Entity, inBuf []byte, inFormat string) (rowI interface{}, err error)

UnmarshalSingleInterface - распарсить строку в interface{}

func (*Service) UnmarshalSingleObject added in v0.3.3

func (s *Service) UnmarshalSingleObject(requestID uint64, entity *_meta.Entity, options *_meta.Options, inBuf []byte, inFormat string, ignoreExtra bool) (row *_meta.Object, err error)

UnmarshalSingleObject - распарсить одну строку в структуру

func (*Service) UpdateEntityMeta

func (s *Service) UpdateEntityMeta(ctx context.Context, inBuf []byte, entityName, format string) (result bool, outBuf []byte, err error)

UpdateEntityMeta обновить метаданные entity

func (*Service) XlsMarshal

func (s *Service) XlsMarshal(ctx context.Context, entityName string, queryOptions _meta.QueryOptions, inFile multipart.File) (outBuf []byte, err error)

XlsMarshal извлечь данные и преобразовать в XLS

Jump to

Keyboard shortcuts

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