package svc

import (
	"audio_transcoder/internal/config"
	"audio_transcoder/pkg/baidu"
	"audio_transcoder/pkg/oss"
	"audio_transcoder/pkg/storage"
)

type ServiceContext struct {
	Config   config.Config
	QiNiuSdk *oss.QiNiuSdk
	AsrSdk   *baidu.AsrSdk
	BoltSdk  *storage.BoltSdk
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:   c,
		QiNiuSdk: oss.NewQiNiuSdk(c.QiNiuConf.AccessKey, c.QiNiuConf.SecretKey, c.QiNiuConf.Bucket, c.QiNiuConf.HostUrl),
		AsrSdk:   baidu.NewAsrSdk(c.BaiduAsrConf.AppID, c.BaiduAsrConf.APIKey, c.BaiduAsrConf.SecretKey),
		BoltSdk:  storage.NewBoltSdk(),
	}
}

func (c *ServiceContext) CloseHandler() {
	c.BoltSdk.Close()
}
