taskcommon

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProgressSubmitted  = "10%"
	ProgressQueued     = "20%"
	ProgressInProgress = "30%"
	ProgressComplete   = "100%"
)

Status-to-progress mapping constants for polling updates.

View Source
const (
	TaskProtocolGenericVideo        = "generic_video_task"
	TaskProtocolLegacySeedanceMedia = "seedance_official_media"
)

Variables

This section is empty.

Functions

func BuildConfiguredTaskURL

func BuildConfiguredTaskURL(baseURL string, path string, values map[string]string) string

func BuildProxyURL

func BuildProxyURL(taskID string) string

BuildProxyURL constructs the video proxy URL using the public task ID. e.g., "https://your-server.com/v1/videos/task_xxxx/content"

func BuildTaskQueryURL

func BuildTaskQueryURL(baseURL string, body map[string]any, fallback string) string

func BuildTaskSubmitURL

func BuildTaskSubmitURL(info *relaycommon.RelayInfo, fallback string) string

func ConfiguredTaskErrorWrapper

func ConfiguredTaskErrorWrapper(err error, code string, statusCode int) *dto.TaskError

func ConvertConfiguredTaskToOpenAIVideo

func ConvertConfiguredTaskToOpenAIVideo(originTask *model.Task) ([]byte, bool, error)

func DecodeLocalTaskID

func DecodeLocalTaskID(id string) (string, error)

DecodeLocalTaskID decodes a base64-encoded upstream operation name.

func DefaultInt

func DefaultInt(val, fallback int) int

DefaultInt returns val if non-zero, otherwise fallback.

func DefaultString

func DefaultString(val, fallback string) string

DefaultString returns val if non-empty, otherwise fallback.

func EncodeLocalTaskID

func EncodeLocalTaskID(name string) string

EncodeLocalTaskID encodes an upstream operation name to a URL-safe base64 string. Used by Gemini/Vertex to store upstream names as task IDs.

func ExtractConfiguredResultURL

func ExtractConfiguredResultURL(data []byte, paths []string) string

func HasTaskProtocolConfig

func HasTaskProtocolConfig(settings dto.ChannelOtherSettings) bool

func IsVideoTaskChannelType

func IsVideoTaskChannelType(channelType int) bool

func MapConfiguredTaskStatus

func MapConfiguredTaskStatus(status string, cfg dto.TaskProtocolConfig) string

func MissingConfiguredTaskIDError

func MissingConfiguredTaskIDError() *dto.TaskError

func NormalizeConfiguredProgress

func NormalizeConfiguredProgress(progress string, status string) string

func NormalizeInternalTaskStatus

func NormalizeInternalTaskStatus(status string) string

func NormalizeTaskProtocolConfig

func NormalizeTaskProtocolConfig(input *dto.TaskProtocolConfig) dto.TaskProtocolConfig

func ParseConfiguredTaskResult

func ParseConfiguredTaskResult(respBody []byte, settings dto.ChannelOtherSettings) (*relaycommon.TaskInfo, bool, error)

func StringFromGJSONPath

func StringFromGJSONPath(data []byte, path string) string

func StripTaskProtocolConfig

func StripTaskProtocolConfig(body map[string]any) map[string]any

func TaskProtocolConfigFromTask

func TaskProtocolConfigFromTask(task *model.Task) (dto.TaskProtocolConfig, bool)

func TimestampFromGJSONPath

func TimestampFromGJSONPath(data []byte, path string) int64

func TryHandleConfiguredSubmitResponse

func TryHandleConfiguredSubmitResponse(c *gin.Context, responseBody []byte, info *relaycommon.RelayInfo) (string, bool, *dto.TaskError)

func UnmarshalMetadata

func UnmarshalMetadata(metadata map[string]any, target any) error

UnmarshalMetadata converts a map[string]any metadata to a typed struct via JSON round-trip. This replaces the repeated pattern: json.Marshal(metadata) → json.Unmarshal(bytes, &target).

func UseConfiguredTaskProtocol

func UseConfiguredTaskProtocol(settings dto.ChannelOtherSettings) bool

func ValidateTaskProtocolSettings

func ValidateTaskProtocolSettings(otherSettings string) error

ValidateTaskProtocolSettings 校验渠道 settings JSON 中的任务协议配置。 仅在配置存在时校验,不解析失败的 JSON 交由渠道其他校验处理。

func WithTaskProtocolConfig

func WithTaskProtocolConfig(body map[string]any, settings dto.ChannelOtherSettings) map[string]any

Types

type BaseBilling

type BaseBilling struct{}

func (BaseBilling) AdjustBillingOnComplete

func (BaseBilling) AdjustBillingOnComplete(_ *model.Task, _ *relaycommon.TaskInfo) int

AdjustBillingOnComplete returns 0 (keep pre-charged amount).

func (BaseBilling) AdjustBillingOnSubmit

func (BaseBilling) AdjustBillingOnSubmit(_ *relaycommon.RelayInfo, _ []byte) map[string]float64

AdjustBillingOnSubmit returns nil (no submit-time adjustment).

func (BaseBilling) EstimateBilling

func (BaseBilling) EstimateBilling(_ *gin.Context, _ *relaycommon.RelayInfo) map[string]float64

EstimateBilling returns nil (no extra ratios; use base model price).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL