package queue

import (
	"fmt"
	"sparrow/pkg/utils"
)

type TopicPartitionInfo struct {
	Topic       string
	TenantId    string
	Partition   int
	MyPartition bool
}

func (a *TopicPartitionInfo) String() string {
	return fmt.Sprintf("%s.%s.%d", a.Topic, a.TenantId, a.Partition)
}

func (a *TopicPartitionInfo) HashCode() string {
	return utils.Md5(a.String())
}

// ResolvePartition 生成info
func ResolvePartition(serviceType, queueName, tenantId, entityId string) *TopicPartitionInfo {
	// TODO:生成主题逻辑
	return &TopicPartitionInfo{
		Topic:       queueName,
		TenantId:    tenantId,
		MyPartition: true,
	}
}
