tag

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestBodyReadErrorMsg        = "request body unmarshall error: %s"
	NotSpecifiedErrorMsg           = "%s is not specified"
	EmptyListErrorMsg              = "%s list is empty"
	MaxMemberLimitExceededErrorMsg = "batch size %d exceeds the limit of %d"
	ResponseWriterCastErrorMsg     = "response writer cast error"
	NotFoundErrorMsg               = "%s tag not found"

	TagMemberLimit = 1000
)
View Source
const (
	DefaultPageSize = 1000
	MaxPageSize     = 5000
)
View Source
const (
	LoggedBatch   = 0
	UnloggedBatch = 1
	CounterBatch  = 2
)
View Source
const (
	TableTagMembersBucketed = "TagMembersBucketed"
	BucketCount             = 1000
	DefaultPageSizeV2       = 500
	MaxPageSizeV2           = 5000
	MaxBatchSizeV2          = 5000
	MaxWorkersV2            = 100
	MaxMembersInTagResponse = 100000 // Max members returned in GetTagById
	MemberFetchChunkSize    = 1000   // Chunk size for memory-safe pagination

	QueryAddMemberBucketed       = `INSERT INTO "TagMembersBucketed" (tag_id, bucket_id, member, created) VALUES (?, ?, ?, ?)`
	QueryRemoveMemberBucketed    = `DELETE FROM "TagMembersBucketed" WHERE tag_id = ? AND bucket_id = ? AND member = ?`
	QueryGetMembersByBucket      = `SELECT member FROM "TagMembersBucketed" WHERE tag_id = ? AND bucket_id = ? AND member > ? LIMIT ?`
	QueryGetMembersByBucketFirst = `SELECT member FROM "TagMembersBucketed" WHERE tag_id = ? AND bucket_id = ? LIMIT ?`

	QueryGetPopulatedBuckets  = `SELECT bucket_id FROM "TagBucketMetadata" WHERE tag_id = ?`
	QueryAddBucketMetadata    = `INSERT INTO "TagBucketMetadata" (tag_id, bucket_id) VALUES (?, ?)`
	QueryRemoveBucketMetadata = `DELETE FROM "TagBucketMetadata" WHERE tag_id = ? AND bucket_id = ?`
	QueryGetAllTagIds         = `SELECT tag_id FROM "TagBucketMetadata"`
	QueryDeleteBucketMembers  = `DELETE FROM "TagMembersBucketed" WHERE tag_id = ? AND bucket_id = ?`
	QueryDeleteBucketMetadata = `DELETE FROM "TagBucketMetadata" WHERE tag_id = ? AND bucket_id = ?`
)
View Source
const (
	CommandDryRun = "dryRun"
	CommandStart  = "start"
	CommandCancel = "cancel"
)

Migration command constants

View Source
const (
	ReasonTagNotFound         = "tag_not_found_in_v1"
	ReasonNoMembers           = "no_members"
	ReasonTypeConversion      = "type_conversion_error"
	ReasonXdasVerification    = "xdas_verification_failed"
	ReasonDatabaseWriteFailed = "database_write_failed"
)

Skip reason constants

View Source
const (
	Prefix   = "t_"
	Template = "%s%s"
)
View Source
const (
	StringToIntConversionErr = "error converting string %s value to int: %s"
	IncorrectRangeErr        = "start range should be greater then end range"
	MinStartPercentage       = 0
	MaxEndPercentage         = 100
)
View Source
const (
	CloneErrorMsg = "error cloning %s tag"
)

Variables

This section is empty.

Functions

func AddAccountRangeToTag

func AddAccountRangeToTag(id string, startRangeStr string, endRangeStr string) error

func AddMembersToTag

func AddMembersToTag(id string, members []string) (int, error)

func AddMembersToTagV2Handler added in v1.0.10

func AddMembersToTagV2Handler(w http.ResponseWriter, r *http.Request)

AddMembersToTagV2Handler - Updated with bucketed implementation

func AddMembersToXconfTag

func AddMembersToXconfTag(id string, members []string) *taggingds.Tag

func AddMembersV2 added in v1.0.10

func AddMembersV2(tagId string, members []string) error

func AddMembersWithXdas added in v1.0.10

func AddMembersWithXdas(tagId string, members []string) error

AddMembersWithXdas adds members to both XDAS and Cassandra (XDAS-first approach)

func CheckBatchSizeExceeded

func CheckBatchSizeExceeded(batchSize int) error

func CleanPercentageRange

func CleanPercentageRange(id string) error

func DeleteOneTag

func DeleteOneTag(id string) error

func DeleteTag

func DeleteTag(id string) error

func DeleteTagV2 added in v1.0.10

func DeleteTagV2(tagId string) error

DeleteTagV2 deletes a tag completely from V2 storage (XDAS and Cassandra) Uses memory-safe chunked deletion to handle tags with millions of members

func DeleteTagV2Handler added in v1.0.10

func DeleteTagV2Handler(w http.ResponseWriter, r *http.Request)

DeleteTagV2Handler deletes a tag and all its members from V2 storage asynchronously

func GetAllTagIds

func GetAllTagIds() ([]string, error)

func GetAllTagIdsV2 added in v1.0.10

func GetAllTagIdsV2() ([]string, error)

GetAllTagIdsV2 returns all tag IDs from V2 tables

func GetAllTags

func GetAllTags() ([]*taggingds.Tag, error)

func GetAllTagsV2Handler added in v1.0.10

func GetAllTagsV2Handler(w http.ResponseWriter, r *http.Request)

GetAllTagsV2Handler returns all tag IDs from V2 storage

func GetGroupServiceConnector

func GetGroupServiceConnector() *http.GroupServiceConnector

func GetGroupServiceSyncConnector

func GetGroupServiceSyncConnector() *http.GroupServiceSyncConnector

func GetMembersV2NonPaginated added in v1.0.10

func GetMembersV2NonPaginated(tagId string) ([]string, bool, error)

GetMembersV2NonPaginated retrieves tag members for non-paginated response (V1 compatibility) Returns up to MaxMembersInTagResponse (100k) members as a plain array

func GetOneTag

func GetOneTag(id string) *taggingds.Tag

func GetTagApiConfig

func GetTagApiConfig() *taggingapi_config.TaggingApiConfig

func GetTagById

func GetTagById(id string) *taggingds.Tag

func GetTagByIdV2 added in v1.0.10

func GetTagByIdV2(tagId string) ([]string, bool, error)

GetTagByIdV2 retrieves a tag with up to MaxMembersInTagResponse members

func GetTagByIdV2Handler added in v1.0.10

func GetTagByIdV2Handler(w http.ResponseWriter, r *http.Request)

GetTagByIdV2Handler retrieves a single tag with its members from V2 storage

func GetTagMembers

func GetTagMembers(id string) ([]string, error)

func GetTagMembersV2Handler added in v1.0.10

func GetTagMembersV2Handler(w http.ResponseWriter, r *http.Request)

GetTagMembersV2Handler - Unified handler supporting both paginated and non-paginated responses Non-paginated mode (V1 compatible): Returns []string with up to 100k members, HTTP 206 if truncated Paginated mode: Returns paginated envelope when limit/cursor params are present

func GetTagsByMember

func GetTagsByMember(member string) ([]string, error)

func GetTagsByMemberHandler

func GetTagsByMemberHandler(w http.ResponseWriter, r *http.Request)

func GetTagsByMemberPercentage

func GetTagsByMemberPercentage(member string) ([]string, error)

func MigrateV1ToV2Handler added in v1.0.10

func MigrateV1ToV2Handler(w http.ResponseWriter, r *http.Request)

MigrateV1ToV2Handler handles the migration from V1 to V2 tag storage

func MigrationStatusHandler added in v1.0.10

func MigrationStatusHandler(w http.ResponseWriter, r *http.Request)

MigrationStatusHandler returns the current migration job status

func RemoveMemberFromTag

func RemoveMemberFromTag(id string, member string) (*taggingds.Tag, error)

func RemoveMemberFromTagV2Handler added in v1.0.10

func RemoveMemberFromTagV2Handler(w http.ResponseWriter, r *http.Request)

RemoveMemberFromTagV2Handler - Updated with bucketed implementation

func RemoveMemberV2WithXdas added in v1.0.10

func RemoveMemberV2WithXdas(tagId string, member string) error

RemoveMemberV2WithXdas removes a single member from both XDAS and Cassandra V2

func RemoveMembersFromTag

func RemoveMembersFromTag(id string, members []string) (int, error)

func RemoveMembersFromTagV2Handler added in v1.0.10

func RemoveMembersFromTagV2Handler(w http.ResponseWriter, r *http.Request)

RemoveMembersFromTagV2Handler - Updated with bucketed implementation

func RemoveMembersV2 added in v1.0.10

func RemoveMembersV2(tagId string, members []string) error

func RemoveMembersV2WithXdas added in v1.0.10

func RemoveMembersV2WithXdas(tagId string, members []string) error

RemoveMembersV2WithXdas removes members from both XDAS and Cassandra (XDAS-first approach)

func RemovePrefixFromTag

func RemovePrefixFromTag(tagId string) string

func SaveTag

func SaveTag(tag *taggingds.Tag) error

func SetTagApiConfig

func SetTagApiConfig(config *taggingapi_config.TaggingApiConfig)

func SetTagPrefix

func SetTagPrefix(tagId string) string

func ToEstbIfMac

func ToEstbIfMac(member string) string

func ToNormalized

func ToNormalized(member string) string

func ToNormalizedEcm

func ToNormalizedEcm(member string) string

Types

type BucketedCursor added in v1.0.10

type BucketedCursor struct {
	BucketId       int    `json:"bucketId"`
	LastMember     string `json:"lastMember,omitempty"`
	TotalCollected int    `json:"totalCollected"`
}

type DryRunResponse added in v1.0.10

type DryRunResponse struct {
	Summary  DryRunSummary  `json:"summary"`
	Tags     map[string]int `json:"tags"`
	Warnings []string       `json:"warnings,omitempty"`
}

DryRunResponse represents the response for a dry run migration

type DryRunSummary added in v1.0.10

type DryRunSummary struct {
	TotalTags           int `json:"totalTags"`
	TotalMembersInXconf int `json:"totalMembersInXconf"`
}

DryRunSummary provides overall statistics for dry run

type MigrationJobManager added in v1.0.10

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

MigrationJobManager manages the migration job lifecycle

func (*MigrationJobManager) CancelJob added in v1.0.10

func (m *MigrationJobManager) CancelJob() error

CancelJob cancels the running migration job

func (*MigrationJobManager) CancelJobComplete added in v1.0.10

func (m *MigrationJobManager) CancelJobComplete(result *MigrationResponse)

CancelJobComplete marks the job as cancelled with partial results

func (*MigrationJobManager) CompleteJob added in v1.0.10

func (m *MigrationJobManager) CompleteJob(result *MigrationResponse)

CompleteJob marks the job as completed with results

func (*MigrationJobManager) FailJob added in v1.0.10

func (m *MigrationJobManager) FailJob(err error)

FailJob marks the job as failed

func (*MigrationJobManager) GetContext added in v1.0.10

func (m *MigrationJobManager) GetContext() context.Context

GetContext returns the current job context

func (*MigrationJobManager) GetStatus added in v1.0.10

func (m *MigrationJobManager) GetStatus() MigrationJobStatus

GetStatus returns the current job status (thread-safe)

func (*MigrationJobManager) StartJob added in v1.0.10

func (m *MigrationJobManager) StartJob(command string) error

StartJob initiates a new migration job

func (*MigrationJobManager) UpdateProgress added in v1.0.10

func (m *MigrationJobManager) UpdateProgress(updateFunc func(*MigrationProgress))

UpdateProgress updates the migration progress (thread-safe)

type MigrationJobState added in v1.0.10

type MigrationJobState string

Migration job state constants

const (
	StateIdle      MigrationJobState = "idle"
	StateRunning   MigrationJobState = "running"
	StateCompleted MigrationJobState = "completed"
	StateFailed    MigrationJobState = "failed"
	StateCancelled MigrationJobState = "cancelled"
)

type MigrationJobStatus added in v1.0.10

type MigrationJobStatus struct {
	State           MigrationJobState  `json:"state"`
	Command         string             `json:"command,omitempty"`
	StartTime       *time.Time         `json:"startTime,omitempty"`
	EndTime         *time.Time         `json:"endTime,omitempty"`
	DurationSeconds float64            `json:"durationSeconds,omitempty"`
	Progress        MigrationProgress  `json:"progress"`
	Result          *MigrationResponse `json:"result,omitempty"`
	Error           string             `json:"error,omitempty"`
}

MigrationJobStatus represents the current state of migration job

type MigrationProgress added in v1.0.10

type MigrationProgress struct {
	TotalTags                      int    `json:"totalTags"`
	ProcessedTags                  int    `json:"processedTags"`
	CurrentTag                     string `json:"currentTag,omitempty"`
	SuccessCount                   int    `json:"successCount"`
	FailureCount                   int    `json:"failureCount"`
	SkippedCount                   int    `json:"skippedCount"`
	CurrentTagTotalMembers         int    `json:"currentTagTotalMembers,omitempty"`
	CurrentTagMembersWritten       int    `json:"currentTagMembersWritten,omitempty"`
	CurrentTagMembersMissingInXdas int    `json:"currentTagMembersMissingInXdas,omitempty"`
}

MigrationProgress tracks real-time progress of migration

type MigrationResponse added in v1.0.10

type MigrationResponse struct {
	Status          string             `json:"status"`
	Summary         MigrationSummary   `json:"summary"`
	FailedTags      []string           `json:"failedTags,omitempty"`
	SkippedTags     []TagMigrationSkip `json:"skippedTags,omitempty"`
	StartTime       string             `json:"startTime"`
	EndTime         string             `json:"endTime"`
	DurationSeconds float64            `json:"durationSeconds"`
}

MigrationResponse represents the response for an actual migration

type MigrationSummary added in v1.0.10

type MigrationSummary struct {
	TotalTags                 int `json:"totalTags"`
	SuccessCount              int `json:"successCount"`
	FailureCount              int `json:"failureCount"`
	SkippedCount              int `json:"skippedCount"`
	TotalMembers              int `json:"totalMembers"`
	TotalMembersWritten       int `json:"totalMembersWritten"`
	TotalMembersMissingInXdas int `json:"totalMembersMissingInXdas"`
}

MigrationSummary provides overall statistics for migration

type PaginatedMembersResponse added in v1.0.10

type PaginatedMembersResponse struct {
	Data       []string `json:"data"`
	NextCursor string   `json:"nextCursor,omitempty"`
	HasMore    bool     `json:"hasMore"`
}

func GetMembersV2Paginated added in v1.0.10

func GetMembersV2Paginated(tagId string, limit int, cursor string) (*PaginatedMembersResponse, error)

type PaginationParams added in v1.0.10

type PaginationParams struct {
	Limit  int    `json:"limit"`
	Cursor string `json:"cursor,omitempty"`
}

type TagMemberStats added in v1.0.10

type TagMemberStats struct {
	TotalMembers         int
	MembersWritten       int
	MembersMissingInXdas int
}

TagMemberStats represents member statistics for a tag migration

type TagMigrationSkip added in v1.0.10

type TagMigrationSkip struct {
	TagId  string `json:"tagId"`
	Reason string `json:"reason"`
}

TagMigrationSkip represents a skipped tag with reason

Jump to

Keyboard shortcuts

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