Documentation
¶
Index ¶
- func ConnectNATS(url string) (*nats.Conn, nats.JetStreamContext, error)
- func GetContentType(extension string) string
- func InitializeMinio(endpoint, accessKey, secretKey, bucket string, useSSL bool) error
- func PublishEvent(subject string, payload interface{}) error
- func PublishPlain(subject string, payload []byte) error
- func SubscribeEvent(subject, durableName string, handler nats.MsgHandler) (*nats.Subscription, error)
- type MinioService
- func (m *MinioService) CheckConnection() error
- func (m *MinioService) DeleteFile(objectName string) error
- func (s *MinioService) DeleteObjectsByPrefix(prefix string) error
- func (m *MinioService) DownloadFile(objectName, localFilePath string) error
- func (m *MinioService) GetFileURL(objectName string) string
- func (s *MinioService) UploadFile(reader io.Reader, size int64, objectName, contentType string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectNATS ¶
ConnectNATS connects to NATS and initializes JetStream and streams. It returns the underlying Conn and JetStreamContext for advanced usage.
func GetContentType ¶
GetContentType Helper function to determine the content type
func InitializeMinio ¶
func PublishEvent ¶
PublishEvent publishes an event via JetStream (durable, stored). subject e.g. "files.uploaded"
func PublishPlain ¶
PublishPlain publishes without JetStream (fire-and-forget). Keep this for compatibility, but prefer PublishEvent for critical events.
func SubscribeEvent ¶
func SubscribeEvent(subject, durableName string, handler nats.MsgHandler) (*nats.Subscription, error)
SubscribeEvent creates a durable, ack-based consumer. handler receives the nats.Msg and is responsible to Ack() when done. durableName should be unique per consumer service (e.g., "file-service-preview-consumer")
Types ¶
type MinioService ¶
func GetMinioService ¶
func GetMinioService() *MinioService
func (*MinioService) CheckConnection ¶
func (m *MinioService) CheckConnection() error
CheckConnection Add this method for health checks
func (*MinioService) DeleteFile ¶
func (m *MinioService) DeleteFile(objectName string) error
func (*MinioService) DeleteObjectsByPrefix ¶
func (s *MinioService) DeleteObjectsByPrefix(prefix string) error
func (*MinioService) DownloadFile ¶
func (m *MinioService) DownloadFile(objectName, localFilePath string) error
func (*MinioService) GetFileURL ¶
func (m *MinioService) GetFileURL(objectName string) string