service

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToParams

func ConvertToParams(vals url.Values) map[string]string

ConvertToParams to convert url.Values to params

func UnmarshalData

func UnmarshalData(b []byte) (v interface{}, err error)

UnmarshalData to unmarshal data

Types

type AuditTrailService

type AuditTrailService interface {
	Find(ctx context.Context, paginationParam repository.PaginationParam) ([]*repository.AuditTrail, error)
	RecordChanges(ctx context.Context, entityName string, entityID int64, opsType repository.OperationType,
		oldData interface{}, newData interface{}) (lastInsertID int64, err error)
}

AuditTrailService contain logic for AuditTrail Controller [mock]

func NewAuditTrailService

func NewAuditTrailService(impl AuditTrailServiceImpl) AuditTrailService

NewAuditTrailService return new instance of AuditTrailService [constructor]

type AuditTrailServiceImpl

type AuditTrailServiceImpl struct {
	dig.In
	AuditTrailRepo repository.AuditTrailRepo
}

AuditTrailServiceImpl is implementation of AuditTrailService

func (*AuditTrailServiceImpl) Find

Find audit trail data

func (*AuditTrailServiceImpl) RecordChanges

func (r *AuditTrailServiceImpl) RecordChanges(ctx context.Context,
	entityName string, entityID int64, opsType repository.OperationType,
	oldData interface{}, newData interface{}) (lastInsertID int64, err error)

RecordChanges insert changes

type CanonicalTagRequest

type CanonicalTagRequest struct {
	ID     int64  `json:"id"`
	RuleID int64  `json:"rule_id"`
	Locale string `json:"locale"`
	Href   string `json:"href"`
}

CanonicalTagRequest is request model for CanonicalTag related method

type CenterService

type CenterService interface {
	AddMetaTag(ctx context.Context, req MetaTagRequest) (*repository.Tag, error)
	UpdateMetaTag(ctx context.Context, req MetaTagRequest) error
	AddTitleTag(ctx context.Context, req TitleTagRequest) (*repository.Tag, error)
	UpdateTitleTag(ctx context.Context, req TitleTagRequest) error
	AddCanonicalTag(ctx context.Context, req CanonicalTagRequest) (*repository.Tag, error)
	UpdateCanonicalTag(ctx context.Context, req CanonicalTagRequest) error
	AddScriptTag(ctx context.Context, req ScriptTagRequest) (*repository.Tag, error)
	UpdateScriptTag(ctx context.Context, req ScriptTagRequest) error
}

CenterService is center related logic [mock]

func NewCenterService

func NewCenterService(impl CenterServiceImpl) CenterService

NewCenterService return new instance of CenterService [constructor]

type CenterServiceImpl

type CenterServiceImpl struct {
	dig.In
	TagService
}

CenterServiceImpl implementation of CenterService

func (*CenterServiceImpl) AddCanonicalTag

func (i *CenterServiceImpl) AddCanonicalTag(ctx context.Context, req CanonicalTagRequest) (tag *repository.Tag, err error)

AddCanonicalTag adds new canonical tag

func (*CenterServiceImpl) AddMetaTag

func (i *CenterServiceImpl) AddMetaTag(ctx context.Context, req MetaTagRequest) (tag *repository.Tag, err error)

AddMetaTag adds new meta tag TODO: Use JSON marshal to set attributes, simple string substitution is prone to be exploited

func (*CenterServiceImpl) AddScriptTag

func (i *CenterServiceImpl) AddScriptTag(ctx context.Context, req ScriptTagRequest) (tag *repository.Tag, err error)

AddScriptTag adds new script tag

func (*CenterServiceImpl) AddTitleTag

func (i *CenterServiceImpl) AddTitleTag(ctx context.Context, req TitleTagRequest) (tag *repository.Tag, err error)

AddTitleTag adds new title tag

func (*CenterServiceImpl) UpdateCanonicalTag

func (i *CenterServiceImpl) UpdateCanonicalTag(ctx context.Context, req CanonicalTagRequest) error

UpdateCanonicalTag updates existing canonical tag

func (*CenterServiceImpl) UpdateMetaTag

func (i *CenterServiceImpl) UpdateMetaTag(ctx context.Context, req MetaTagRequest) error

UpdateMetaTag updates existing meta tag

func (*CenterServiceImpl) UpdateScriptTag

func (i *CenterServiceImpl) UpdateScriptTag(ctx context.Context, req ScriptTagRequest) error

UpdateScriptTag updates existing script tag

func (*CenterServiceImpl) UpdateTitleTag

func (i *CenterServiceImpl) UpdateTitleTag(ctx context.Context, req TitleTagRequest) error

UpdateTitleTag updates existing title tag

type DataSourceService

type DataSourceService interface {
	repository.DataSourceRepo
}

DataSourceService contain logic for DataSourceController [mock]

func NewDataSourceService

func NewDataSourceService(impl DataSourceServiceImpl) DataSourceService

NewDataSourceService return new instance of DataSourceService [constructor]

type DataSourceServiceImpl

type DataSourceServiceImpl struct {
	dig.In
	dbtxn.Transactional
	repository.DataSourceRepo
	AuditTrailService AuditTrailService
	HistoryService    HistoryService
}

DataSourceServiceImpl is implementation of DataSourceService

func (*DataSourceServiceImpl) Delete

func (s *DataSourceServiceImpl) Delete(ctx context.Context, id int64) (err error)

Delete data source

func (*DataSourceServiceImpl) Insert

func (s *DataSourceServiceImpl) Insert(ctx context.Context, ds repository.DataSource) (newDsID int64, err error)

Insert data source

func (*DataSourceServiceImpl) Update

Update data source

type HistoryService

type HistoryService interface {
	RecordHistory(ctx context.Context, entityFrom string, entityID int64,
		data interface{}) (lastInsertID int64, err error)
}

HistoryService contain logic for History Controller [mock]

func NewHistoryService

func NewHistoryService(impl HistoryServiceImpl) HistoryService

NewHistoryService return new instance of HistoryService [constructor]

type HistoryServiceImpl

type HistoryServiceImpl struct {
	dig.In
	HistoryRepo repository.HistoryRepo
}

HistoryServiceImpl is implementation of HistoryService

func (*HistoryServiceImpl) RecordHistory

func (r *HistoryServiceImpl) RecordHistory(ctx context.Context,
	entityFrom string, entityID int64,
	data interface{}) (lastInsertID int64, err error)

RecordHistory insert history

type IDataSource

type IDataSource repository.DataSource

IDataSource is datasource after interpolate with data

type ITag

type ITag repository.Tag

ITag is tag after interpolate with data

type MatchRequest

type MatchRequest struct {
	Path string `json:"path"`
}

MatchRequest is request for match rule

type MatchResponse

type MatchResponse struct {
	RuleID    int64             `json:"rule_id"`
	PathParam map[string]string `json:"path_param"`
}

MatchResponse is response of match rule

type MetaTagRequest

type MetaTagRequest struct {
	ID      int64  `json:"id"`
	RuleID  int64  `json:"rule_id"`
	Locale  string `json:"locale"`
	Name    string `json:"name"`
	Content string `json:"content"`
}

MetaTagRequest is request model for MetaTag related method

type MetricService

type MetricService interface {
	metric.ReportRepo
}

MetricService contain logic for MetricsUnmatchedController [mock]

func NewMetricService

func NewMetricService(impl MetricServiceImpl) MetricService

NewMetricService return new instance of MetricsRuleMatchingService [constructor]

type MetricServiceImpl

type MetricServiceImpl struct {
	dig.In
	metric.ReportRepo
}

MetricServiceImpl is implementation of MetricsRuleMatchingService

type ProviderService

type ProviderService interface {
	Match(context.Context, MatchRequest) (*MatchResponse, error)
	FetchTags(ctx context.Context, id int64, values url.Values) ([]*ITag, error)
	FetchTagsWithCache(ctx context.Context, id int64, values url.Values, pragma *cachekit.Pragma) ([]*ITag, error)
}

ProviderService contain logic for provider api [mock]

func NewProviderService

func NewProviderService(impl ProviderServiceImpl) ProviderService

NewProviderService return new instance of ProviderService [constructor]

type ProviderServiceImpl

ProviderServiceImpl is implementation of Provider

func (*ProviderServiceImpl) FetchTags

func (p *ProviderServiceImpl) FetchTags(
	ctx context.Context,
	ruleID int64,
	values url.Values,
) (itags []*ITag, err error)

FetchTags handle logic for fetching tag

func (*ProviderServiceImpl) FetchTagsWithCache

func (p *ProviderServiceImpl) FetchTagsWithCache(
	ctx context.Context,
	ruleID int64,
	values url.Values,
	pragma *cachekit.Pragma,
) (itags []*ITag, err error)

FetchTagsWithCache is same with FetchTag but with tag

func (*ProviderServiceImpl) Match

func (p *ProviderServiceImpl) Match(ctx context.Context, req MatchRequest) (resp *MatchResponse, err error)

Match url with its rule

type RuleService

type RuleService interface {
	FindOne(ctx context.Context, id int64) (*repository.Rule, error)
	Find(ctx context.Context, paginationParam repository.PaginationParam) ([]*repository.Rule, error)
	Insert(ctx context.Context, rule repository.Rule) (lastInsertID int64, err error)
	Delete(ctx context.Context, id int64) error
	Update(ctx context.Context, rule repository.Rule) error
}

RuleService contain logic for Rule Controller [mock]

func NewRuleService

func NewRuleService(impl RuleServiceImpl) RuleService

NewRuleService return new instance of RuleService [constructor]

type RuleServiceImpl

type RuleServiceImpl struct {
	dig.In
	RuleRepo    repository.RuleRepo
	URLSyncRepo repository.URLSyncRepo
	AuditTrailService
	HistoryService
	dbtxn.Transactional
}

RuleServiceImpl is implementation of RuleService

func (*RuleServiceImpl) Delete

func (r *RuleServiceImpl) Delete(ctx context.Context, id int64) (err error)

Delete rule

func (*RuleServiceImpl) Find

func (r *RuleServiceImpl) Find(ctx context.Context, paginationParam repository.PaginationParam) (list []*repository.Rule, err error)

Find rule

func (*RuleServiceImpl) FindOne

func (r *RuleServiceImpl) FindOne(ctx context.Context, id int64) (rule *repository.Rule, err error)

FindOne rule

func (*RuleServiceImpl) Insert

func (r *RuleServiceImpl) Insert(ctx context.Context, rule repository.Rule) (newRuleID int64, err error)

Insert rule

func (*RuleServiceImpl) Update

func (r *RuleServiceImpl) Update(ctx context.Context, rule repository.Rule) (err error)

Update rule

type ScriptTagRequest

type ScriptTagRequest struct {
	ID     int64  `json:"id"`
	Type   string `json:"type"`
	RuleID int64  `json:"rule_id"`
	Locale string `json:"locale"`
	Source string `json:"source"`
}

ScriptTagRequest is request model for ScriptTag related method

type TagService

type TagService interface {
	repository.TagRepo
}

TagService contain logic for TagController [mock]

func NewTagService

func NewTagService(impl TagServiceImpl) TagService

NewTagService return new instance of TagService [constructor]

type TagServiceImpl

type TagServiceImpl struct {
	dig.In
	repository.TagRepo
	dbtxn.Transactional
	AuditTrailService AuditTrailService
	HistoryService    HistoryService
}

TagServiceImpl is implementation of TagService

func (*TagServiceImpl) Delete

func (s *TagServiceImpl) Delete(ctx context.Context, id int64) (err error)

Delete tag

func (*TagServiceImpl) Insert

func (s *TagServiceImpl) Insert(ctx context.Context, data repository.Tag) (newID int64, err error)

Insert tag

func (*TagServiceImpl) Update

func (s *TagServiceImpl) Update(ctx context.Context, data repository.Tag) (err error)

Update tag

type TitleTagRequest

type TitleTagRequest struct {
	ID     int64  `json:"id"`
	RuleID int64  `json:"rule_id"`
	Locale string `json:"locale"`
	Title  string `json:"title"`
}

TitleTagRequest is request model for TitleTag related method

type URLService

type URLService interface {
	FullSync(context.Context) error
	Sync(context.Context) error
	Match(url string) (int64, map[string]string)
	DumpTree() string
	Get(path string, pvalues []string) (data interface{}, pnames []string)
	Delete(id int64) bool
	Insert(id int64, key string)
	Update(id int64, key string)
	Count() int
}

URLService contain logic of url [mock]

func NewURLService

func NewURLService(svc repository.URLSyncRepo) URLService

NewURLService return new instance of URLService [constructor]

type URLServiceImpl

type URLServiceImpl struct {
	dig.In
	repository.URLSyncRepo
	urlstore.Store
	LatestVersion int
}

URLServiceImpl is implementation of URLService

func (*URLServiceImpl) DumpTree

func (s *URLServiceImpl) DumpTree() string

DumpTree to debug purpose

func (*URLServiceImpl) FullSync

func (s *URLServiceImpl) FullSync(ctx context.Context) error

FullSync to sync from url-sync data to in-memory url-store from beginning

func (*URLServiceImpl) Insert

func (s *URLServiceImpl) Insert(id int64, key string)

Insert to store

func (*URLServiceImpl) Match

func (s *URLServiceImpl) Match(url string) (int64, map[string]string)

Match return rule id and parameter map

func (*URLServiceImpl) Sync

func (s *URLServiceImpl) Sync(ctx context.Context) error

Sync to from url-sync data to in-memory url-store based on diff

func (*URLServiceImpl) Update

func (s *URLServiceImpl) Update(id int64, key string)

Update store

Jump to

Keyboard shortcuts

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