package provider import ( "edge-infra.dev/pkg/edge/datasync/chirp/model" "edge-infra.dev/pkg/edge/datasync/internal/config" repository "edge-infra.dev/pkg/edge/datasync/internal/outbox" ) type fileSystemProvider struct { partition int outboxes []string bulkSizePerOutbox map[string]int configChirp *config.Config } func NewFileSystemProvider(partition int, chirpConfig *config.Config) MessageProvider { return &fileSystemProvider{ partition: partition, outboxes: config.GetRoutes(chirpConfig), bulkSizePerOutbox: config.GetBulkSizes(chirpConfig), configChirp: chirpConfig, } } func (p *fileSystemProvider) GetMessages() map[string]model.Message { for _, outbox := range p.outboxes { var fileRepository = repository.NewFileRepository(config.GetOutboxPath(p.configChirp), outbox, p.partition) bulkSize := p.bulkSizePerOutbox[outbox] messages := fileRepository.GetMessages(bulkSize) if len(messages) > 0 { return messages } } return nil }