interface.go 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. package plugin
  2. import "context"
  3. // MerchantData is the standard output format for all collector plugins.
  4. // Every plugin must produce data in this shape via the callback.
  5. type MerchantData struct {
  6. TgUsername string `json:"tg_username"` // required — no tg_username, no insert
  7. TgLink string `json:"tg_link"`
  8. MerchantName string `json:"merchant_name"`
  9. Website string `json:"website"`
  10. Email string `json:"email"`
  11. Phone string `json:"phone"`
  12. SourceType string `json:"source_type"` // web / tg_channel / github
  13. SourceName string `json:"source_name"` // specific source (page title / channel name)
  14. SourceURL string `json:"source_url"` // source URL
  15. OriginalText string `json:"original_text"` // raw text for audit
  16. IndustryTag string `json:"industry_tag"`
  17. }
  18. // Collector is the interface every collection plugin must implement.
  19. type Collector interface {
  20. // Name returns the plugin name, e.g. "web_collector".
  21. Name() string
  22. // Run starts collection. For every merchant found, call callback.
  23. // cfg carries plugin-specific configuration (keywords, limits, etc.).
  24. // The function should respect ctx cancellation for graceful shutdown.
  25. Run(ctx context.Context, cfg map[string]any, callback func(MerchantData)) error
  26. // Stop requests graceful shutdown from outside.
  27. Stop() error
  28. }