From 5a154dcc91ce547baf2203c42b727b326a40e571 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 13 Jan 2020 17:00:02 +0200 Subject: [PATCH] Updated comments --- engine/attributes.go | 12 ++++++------ engine/datamanager.go | 3 ++- engine/version.go | 8 ++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/engine/attributes.go b/engine/attributes.go index b87bf61aa..6078256fd 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -27,6 +27,7 @@ import ( "github.com/cgrates/cgrates/utils" ) +// NewAttributeService returns a new AttributeService func NewAttributeService(dm *DataManager, filterS *FilterS, cgrcfg *config.CGRConfig) (*AttributeService, error) { return &AttributeService{ @@ -36,6 +37,7 @@ func NewAttributeService(dm *DataManager, filterS *FilterS, }, nil } +// AttributeService the service for the API type AttributeService struct { dm *DataManager filterS *FilterS @@ -122,12 +124,7 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent return } -// AttrSFldNameValue is a helper struct for AttrSDigest deserialization -type AttrSFieldNameValue struct { - FieldName string - FieldValue string -} - +// AttrSProcessEventReply reply used for proccess event type AttrSProcessEventReply struct { MatchedProfiles []string AlteredFields []string @@ -151,6 +148,7 @@ func (attrReply *AttrSProcessEventReply) Digest() (rplyDigest string) { return } +// AttrArgsProcessEvent arguments used for proccess event type AttrArgsProcessEvent struct { AttributeIDs []string Context *string // attach the event to a context @@ -272,6 +270,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) ( return } +// V1GetAttributeForEvent returns the AttributeProfile that matches the event func (alS *AttributeService) V1GetAttributeForEvent(args *AttrArgsProcessEvent, attrPrfl *AttributeProfile) (err error) { if args.CGREvent == nil { @@ -288,6 +287,7 @@ func (alS *AttributeService) V1GetAttributeForEvent(args *AttrArgsProcessEvent, return } +// V1ProcessEvent proccess the event and returns the result func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, reply *AttrSProcessEventReply) (err error) { if args.CGREvent == nil { diff --git a/engine/datamanager.go b/engine/datamanager.go index d83153eed..5c15bc88e 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -1773,6 +1773,7 @@ func (dm *DataManager) RemoveSupplierProfile(tenant, id, transactionID string, w return } +// GetAttributeProfile returns the AttributeProfile with the given id func (dm *DataManager) GetAttributeProfile(tenant, id string, cacheRead, cacheWrite bool, transactionID string) (attrPrfl *AttributeProfile, err error) { tntID := utils.ConcatenatedKey(tenant, id) @@ -1786,7 +1787,7 @@ func (dm *DataManager) GetAttributeProfile(tenant, id string, cacheRead, cacheWr } if strings.HasPrefix(id, utils.Meta) { attrPrfl, err = NewAttributeFromInline(tenant, id) - } else if dm == nil { // in case we want the filter from dataDB but the connection to dataDB a optional (e.g. SessionS) + } else if dm == nil { err = utils.ErrNoDatabaseConn return } else { diff --git a/engine/version.go b/engine/version.go index 2fbf98e7a..9b4378450 100644 --- a/engine/version.go +++ b/engine/version.go @@ -56,6 +56,7 @@ func init() { // Versions will keep trac of various item versions type Versions map[string]int64 // map[item]versionNr +// CheckVersions returns error if the db needs migration func CheckVersions(storage Storage) error { // get current db version storType := storage.GetStorageType() @@ -104,14 +105,17 @@ func setDBVersions(storage Storage, overwrite bool) (err error) { return } +// SetDBVersions sets the version without overwriting them func SetDBVersions(storage Storage) (err error) { return setDBVersions(storage, false) } +// OverwriteDBVersions sets the version overwriting them func OverwriteDBVersions(storage Storage) (err error) { return setDBVersions(storage, true) } +// Compare returns the migration message if the versions are not the latest func (vers Versions) Compare(curent Versions, storType string, isDataDB bool) string { var message map[string]string switch storType { @@ -136,6 +140,7 @@ func (vers Versions) Compare(curent Versions, storType string, isDataDB bool) st return "" } +// CurrentDataDBVersions returns the needed DataDB versions func CurrentDataDBVersions() Versions { return Versions{ utils.StatS: 3, @@ -161,6 +166,7 @@ func CurrentDataDBVersions() Versions { } } +// CurrentStorDBVersions returns the needed StorDB versions func CurrentStorDBVersions() Versions { return Versions{ utils.CostDetails: 2, @@ -190,6 +196,7 @@ func CurrentStorDBVersions() Versions { } } +// CurrentAllDBVersions returns the both DataDB and StorDB versions func CurrentAllDBVersions() Versions { dataDbVersions := CurrentDataDBVersions() storDbVersions := CurrentStorDBVersions() @@ -203,6 +210,7 @@ func CurrentAllDBVersions() Versions { return allVersions } +// CurrentDBVersions returns versions based on dbType func CurrentDBVersions(storType string, isDataDB bool) Versions { switch storType { case utils.MONGO: