mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
refactor(plugins): update function signatures to return values directly instead of response structs
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
312a31f688
commit
810ee687fa
@ -67,11 +67,7 @@ type {{responseType .}} struct {
|
||||
{{- if .Doc}}
|
||||
{{formatDoc .Doc}}
|
||||
{{- end}}
|
||||
{{- if .IsErrorOnly}}
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) error {
|
||||
{{- else}}
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) (*{{responseType .}}, error) {
|
||||
{{- end}}
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) {{.ReturnSignature}} {
|
||||
{{- if .HasParams}}
|
||||
// Marshal request to JSON
|
||||
req := {{requestType .}}{
|
||||
@ -81,7 +77,7 @@ func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return {{if not .IsErrorOnly}}nil, {{end}}err
|
||||
return {{if .HasReturns}}{{.ZeroValues}}{{end}}{{if and .HasReturns .HasError}}, {{end}}{{if .HasError}}err{{end}}
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -115,15 +111,17 @@ func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{
|
||||
// Parse the response
|
||||
var response {{responseType .}}
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return {{if .HasReturns}}{{.ZeroValues}}{{end}}{{if and .HasReturns .HasError}}, {{end}}{{if .HasError}}err{{end}}
|
||||
}
|
||||
{{- if .HasError}}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return {{if .HasReturns}}{{.ZeroValues}}, {{end}}errors.New(response.Error)
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
return &response, nil
|
||||
return {{range $i, $r := .Returns}}{{if $i}}, {{end}}response.{{title $r.Name}}{{end}}{{if and .HasReturns .HasError}}, {{end}}{{if .HasError}}nil{{end}}
|
||||
{{- end}}
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
@ -52,13 +52,7 @@ type {{responseType .}} struct {
|
||||
{{- if .Doc}}
|
||||
{{formatDoc .Doc}}
|
||||
{{- end}}
|
||||
{{- if .IsErrorOnly}}
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) error {
|
||||
panic("{{$.Package}}: {{$.Service.Name}}{{.Name}} is only available in WASM plugins")
|
||||
}
|
||||
{{- else}}
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) (*{{responseType .}}, error) {
|
||||
func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{$p.Name}} {{$p.Type}}{{end}}) {{.ReturnSignature}} {
|
||||
panic("{{$.Package}}: {{$.Service.Name}}{{.Name}} is only available in WASM plugins")
|
||||
}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
||||
@ -206,6 +206,76 @@ func (m Method) IsErrorOnly() bool {
|
||||
return m.HasError && !m.HasReturns()
|
||||
}
|
||||
|
||||
// IsSingleReturn returns true if the method has exactly one return value (excluding error).
|
||||
func (m Method) IsSingleReturn() bool {
|
||||
return len(m.Returns) == 1
|
||||
}
|
||||
|
||||
// IsMultiReturn returns true if the method has multiple return values (excluding error).
|
||||
func (m Method) IsMultiReturn() bool {
|
||||
return len(m.Returns) > 1
|
||||
}
|
||||
|
||||
// ReturnSignature returns the Go return type signature for the wrapper function.
|
||||
// For error-only: "error"
|
||||
// For single return with error: "(Type, error)"
|
||||
// For single return no error: "Type"
|
||||
// For multi return: "(Type1, Type2, ..., error)"
|
||||
func (m Method) ReturnSignature() string {
|
||||
if m.IsErrorOnly() {
|
||||
return "error"
|
||||
}
|
||||
var parts []string
|
||||
for _, r := range m.Returns {
|
||||
parts = append(parts, r.Type)
|
||||
}
|
||||
if m.HasError {
|
||||
parts = append(parts, "error")
|
||||
}
|
||||
// Single return without error doesn't need parentheses
|
||||
if len(parts) == 1 {
|
||||
return parts[0]
|
||||
}
|
||||
return "(" + strings.Join(parts, ", ") + ")"
|
||||
}
|
||||
|
||||
// ZeroValues returns the zero value expressions for all return types (excluding error).
|
||||
// Used for error return statements like "return "", false, err".
|
||||
func (m Method) ZeroValues() string {
|
||||
var zeros []string
|
||||
for _, r := range m.Returns {
|
||||
zeros = append(zeros, zeroValue(r.Type))
|
||||
}
|
||||
return strings.Join(zeros, ", ")
|
||||
}
|
||||
|
||||
// zeroValue returns the zero value for a Go type.
|
||||
func zeroValue(typ string) string {
|
||||
switch {
|
||||
case typ == "string":
|
||||
return `""`
|
||||
case typ == "bool":
|
||||
return "false"
|
||||
case typ == "int", typ == "int8", typ == "int16", typ == "int32", typ == "int64",
|
||||
typ == "uint", typ == "uint8", typ == "uint16", typ == "uint32", typ == "uint64",
|
||||
typ == "float32", typ == "float64":
|
||||
return "0"
|
||||
case typ == "[]byte":
|
||||
return "nil"
|
||||
case strings.HasPrefix(typ, "[]"):
|
||||
return "nil"
|
||||
case strings.HasPrefix(typ, "map["):
|
||||
return "nil"
|
||||
case strings.HasPrefix(typ, "*"):
|
||||
return "nil"
|
||||
case typ == "any", typ == "interface{}":
|
||||
return "nil"
|
||||
default:
|
||||
// For custom struct types, return empty struct
|
||||
return typ + "{}"
|
||||
}
|
||||
}
|
||||
|
||||
// Param represents a method parameter or return value.
|
||||
type Param struct {
|
||||
Name string // Parameter name
|
||||
|
||||
@ -31,7 +31,7 @@ type CodecEncodeResponse struct {
|
||||
}
|
||||
|
||||
// CodecEncode calls the codec_encode host function.
|
||||
func CodecEncode(data []byte) (*CodecEncodeResponse, error) {
|
||||
func CodecEncode(data []byte) ([]byte, error) {
|
||||
// Marshal request to JSON
|
||||
req := CodecEncodeRequest{
|
||||
Data: data,
|
||||
@ -61,5 +61,5 @@ func CodecEncode(data []byte) (*CodecEncodeResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
@ -31,14 +31,14 @@ type CounterCountResponse struct {
|
||||
}
|
||||
|
||||
// CounterCount calls the counter_count host function.
|
||||
func CounterCount(name string) (*CounterCountResponse, error) {
|
||||
func CounterCount(name string) int32 {
|
||||
// Marshal request to JSON
|
||||
req := CounterCountRequest{
|
||||
Name: name,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -53,13 +53,8 @@ func CounterCount(name string) (*CounterCountResponse, error) {
|
||||
// Parse the response
|
||||
var response CounterCountResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value
|
||||
}
|
||||
|
||||
@ -31,14 +31,14 @@ type EchoEchoResponse struct {
|
||||
}
|
||||
|
||||
// EchoEcho calls the echo_echo host function.
|
||||
func EchoEcho(message string) (*EchoEchoResponse, error) {
|
||||
func EchoEcho(message string) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := EchoEchoRequest{
|
||||
Message: message,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -53,13 +53,13 @@ func EchoEcho(message string) (*EchoEchoResponse, error) {
|
||||
// Parse the response
|
||||
var response EchoEchoResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Reply, nil
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ type ListItemsResponse struct {
|
||||
}
|
||||
|
||||
// ListItems calls the list_items host function.
|
||||
func ListItems(name string, filter Filter) (*ListItemsResponse, error) {
|
||||
func ListItems(name string, filter Filter) (int32, error) {
|
||||
// Marshal request to JSON
|
||||
req := ListItemsRequest{
|
||||
Name: name,
|
||||
@ -45,7 +45,7 @@ func ListItems(name string, filter Filter) (*ListItemsResponse, error) {
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -60,13 +60,13 @@ func ListItems(name string, filter Filter) (*ListItemsResponse, error) {
|
||||
// Parse the response
|
||||
var response ListItemsResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return 0, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Count, nil
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ type MathAddResponse struct {
|
||||
}
|
||||
|
||||
// MathAdd calls the math_add host function.
|
||||
func MathAdd(a int32, b int32) (*MathAddResponse, error) {
|
||||
func MathAdd(a int32, b int32) (int32, error) {
|
||||
// Marshal request to JSON
|
||||
req := MathAddRequest{
|
||||
A: a,
|
||||
@ -40,7 +40,7 @@ func MathAdd(a int32, b int32) (*MathAddResponse, error) {
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -55,13 +55,13 @@ func MathAdd(a int32, b int32) (*MathAddResponse, error) {
|
||||
// Parse the response
|
||||
var response MathAddResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return 0, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ type MetaSetRequest struct {
|
||||
}
|
||||
|
||||
// MetaGet calls the meta_get host function.
|
||||
func MetaGet(key string) (*MetaGetResponse, error) {
|
||||
func MetaGet(key string) (any, error) {
|
||||
// Marshal request to JSON
|
||||
req := MetaGetRequest{
|
||||
Key: key,
|
||||
@ -71,7 +71,7 @@ func MetaGet(key string) (*MetaGetResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, nil
|
||||
}
|
||||
|
||||
// MetaSet calls the meta_set host function.
|
||||
|
||||
@ -37,14 +37,14 @@ type SearchFindResponse struct {
|
||||
}
|
||||
|
||||
// SearchFind calls the search_find host function.
|
||||
func SearchFind(query string) (*SearchFindResponse, error) {
|
||||
func SearchFind(query string) ([]Result, int32, error) {
|
||||
// Marshal request to JSON
|
||||
req := SearchFindRequest{
|
||||
Query: query,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, 0, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -59,13 +59,13 @@ func SearchFind(query string) (*SearchFindResponse, error) {
|
||||
// Parse the response
|
||||
var response SearchFindResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return nil, 0, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Results, response.Total, nil
|
||||
}
|
||||
|
||||
@ -37,14 +37,14 @@ type StoreSaveResponse struct {
|
||||
}
|
||||
|
||||
// StoreSave calls the store_save host function.
|
||||
func StoreSave(item Item) (*StoreSaveResponse, error) {
|
||||
func StoreSave(item Item) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := StoreSaveRequest{
|
||||
Item: item,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -59,13 +59,13 @@ func StoreSave(item Item) (*StoreSaveResponse, error) {
|
||||
// Parse the response
|
||||
var response StoreSaveResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Id, nil
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ type UsersGetResponse struct {
|
||||
}
|
||||
|
||||
// UsersGet calls the users_get host function.
|
||||
func UsersGet(id *string, filter *User) (*UsersGetResponse, error) {
|
||||
func UsersGet(id *string, filter *User) (*User, error) {
|
||||
// Marshal request to JSON
|
||||
req := UsersGetRequest{
|
||||
Id: id,
|
||||
@ -69,5 +69,5 @@ func UsersGet(id *string, filter *User) (*UsersGetResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
@ -109,11 +109,11 @@ func parseTickerSymbols(tickerConfig string) []string {
|
||||
// connectAndSubscribe connects to Coinbase WebSocket and subscribes to tickers
|
||||
func connectAndSubscribe(tickers []string) error {
|
||||
// Connect to WebSocket using host function
|
||||
resp, err := host.WebSocketConnect(coinbaseWSEndpoint, nil, connectionID)
|
||||
newConnID, err := host.WebSocketConnect(coinbaseWSEndpoint, nil, connectionID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("WebSocket connection error: %w", err)
|
||||
}
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("Connected to Coinbase WebSocket API (connection: %s)", resp.NewConnectionID))
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("Connected to Coinbase WebSocket API (connection: %s)", newConnID))
|
||||
|
||||
// Subscribe to ticker channel
|
||||
subscription := CoinbaseSubscription{
|
||||
|
||||
@ -75,17 +75,17 @@ func getConfig() (clientID string, users map[string]string, err error) {
|
||||
|
||||
// getImageURL retrieves the track artwork URL.
|
||||
func getImageURL(trackID string) string {
|
||||
resp, err := host.ArtworkGetTrackUrl(trackID, 300)
|
||||
artworkURL, err := host.ArtworkGetTrackUrl(trackID, 300)
|
||||
if err != nil {
|
||||
pdk.Log(pdk.LogWarn, fmt.Sprintf("Failed to get artwork URL: %v", err))
|
||||
return ""
|
||||
}
|
||||
|
||||
// Don't use localhost URLs
|
||||
if strings.HasPrefix(resp.Url, "http://localhost") {
|
||||
if strings.HasPrefix(artworkURL, "http://localhost") {
|
||||
return ""
|
||||
}
|
||||
return resp.Url
|
||||
return artworkURL
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@ -89,10 +89,10 @@ func processImage(imageURL, clientID, token string, isDefaultImage bool) (string
|
||||
|
||||
// Check cache first
|
||||
cacheKey := fmt.Sprintf("discord.image.%x", imageURL)
|
||||
cacheResp, err := host.CacheGetString(cacheKey)
|
||||
if err == nil && cacheResp.Exists {
|
||||
cachedValue, exists, err := host.CacheGetString(cacheKey)
|
||||
if err == nil && exists {
|
||||
pdk.Log(pdk.LogDebug, fmt.Sprintf("Cache hit for image URL: %s", imageURL))
|
||||
return cacheResp.Value, nil
|
||||
return cachedValue, nil
|
||||
}
|
||||
|
||||
// Process via Discord API
|
||||
@ -208,13 +208,13 @@ func getDiscordGateway() (string, error) {
|
||||
|
||||
// sendHeartbeat sends a heartbeat to Discord.
|
||||
func sendHeartbeat(username string) error {
|
||||
cacheResp, err := host.CacheGetInt(fmt.Sprintf("discord.seq.%s", username))
|
||||
seqNum, _, err := host.CacheGetInt(fmt.Sprintf("discord.seq.%s", username))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get sequence number: %w", err)
|
||||
}
|
||||
|
||||
pdk.Log(pdk.LogDebug, fmt.Sprintf("Sending heartbeat for user %s: %d", username, cacheResp.Value))
|
||||
return sendMessage(username, heartbeatOpCode, cacheResp.Value)
|
||||
pdk.Log(pdk.LogDebug, fmt.Sprintf("Sending heartbeat for user %s: %d", username, seqNum))
|
||||
return sendMessage(username, heartbeatOpCode, seqNum)
|
||||
}
|
||||
|
||||
// cleanupFailedConnection cleans up a failed Discord connection.
|
||||
@ -284,11 +284,11 @@ func connect(username, token string) error {
|
||||
|
||||
// Schedule heartbeats for this user/connection
|
||||
cronExpr := fmt.Sprintf("@every %ds", heartbeatInterval)
|
||||
schedResp, err := host.SchedulerScheduleRecurring(cronExpr, payloadHeartbeat, username)
|
||||
scheduleID, err := host.SchedulerScheduleRecurring(cronExpr, payloadHeartbeat, username)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to schedule heartbeat: %w", err)
|
||||
}
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("Scheduled heartbeat for user %s with ID %s", username, schedResp.NewScheduleID))
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("Scheduled heartbeat for user %s with ID %s", username, scheduleID))
|
||||
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("Successfully authenticated user %s", username))
|
||||
return nil
|
||||
|
||||
@ -519,6 +519,31 @@ var _ = Describe("CacheService Integration", Ordered, func() {
|
||||
Expect(output.BytesVal).To(Equal(testBytes))
|
||||
})
|
||||
|
||||
It("should handle binary data with null bytes through WASM", func() {
|
||||
ctx := GinkgoT().Context()
|
||||
|
||||
// Binary data with null bytes, high bytes, and other edge cases
|
||||
binaryData := []byte{0x00, 0x01, 0x02, 0xFF, 0xFE, 0x00, 0x80, 0x7F}
|
||||
|
||||
// Set binary bytes
|
||||
_, err := callTestCache(ctx, testCacheInput{
|
||||
Operation: "set_bytes",
|
||||
Key: "binary_test",
|
||||
BytesVal: binaryData,
|
||||
TTLSeconds: 300,
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Get binary bytes and verify exact match
|
||||
output, err := callTestCache(ctx, testCacheInput{
|
||||
Operation: "get_bytes",
|
||||
Key: "binary_test",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(output.Exists).To(BeTrue())
|
||||
Expect(output.BytesVal).To(Equal(binaryData))
|
||||
})
|
||||
|
||||
It("should check if key exists", func() {
|
||||
ctx := GinkgoT().Context()
|
||||
|
||||
|
||||
@ -570,6 +570,30 @@ var _ = Describe("KVStoreService Integration", Ordered, func() {
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("storage limit exceeded"))
|
||||
})
|
||||
|
||||
It("should handle binary data with null bytes through WASM", func() {
|
||||
ctx := GinkgoT().Context()
|
||||
|
||||
// Binary data with null bytes, high bytes, and other edge cases
|
||||
binaryData := []byte{0x00, 0x01, 0x02, 0xFF, 0xFE, 0x00, 0x80, 0x7F}
|
||||
|
||||
// Set binary value
|
||||
_, err := callTestKVStore(ctx, testKVStoreInput{
|
||||
Operation: "set",
|
||||
Key: "binary_test",
|
||||
Value: binaryData,
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Get binary value and verify exact match
|
||||
output, err := callTestKVStore(ctx, testKVStoreInput{
|
||||
Operation: "get",
|
||||
Key: "binary_test",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(output.Exists).To(BeTrue())
|
||||
Expect(output.Value).To(Equal(binaryData))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Database Isolation", func() {
|
||||
|
||||
@ -90,7 +90,7 @@ type ArtworkGetPlaylistUrlResponse struct {
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, error) {
|
||||
func ArtworkGetArtistUrl(id string, size int32) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := ArtworkGetArtistUrlRequest{
|
||||
Id: id,
|
||||
@ -98,7 +98,7 @@ func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, e
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -113,15 +113,15 @@ func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, e
|
||||
// Parse the response
|
||||
var response ArtworkGetArtistUrlResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Url, nil
|
||||
}
|
||||
|
||||
// ArtworkGetAlbumUrl calls the artwork_getalbumurl host function.
|
||||
@ -132,7 +132,7 @@ func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, e
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, error) {
|
||||
func ArtworkGetAlbumUrl(id string, size int32) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := ArtworkGetAlbumUrlRequest{
|
||||
Id: id,
|
||||
@ -140,7 +140,7 @@ func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, err
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -155,15 +155,15 @@ func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, err
|
||||
// Parse the response
|
||||
var response ArtworkGetAlbumUrlResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Url, nil
|
||||
}
|
||||
|
||||
// ArtworkGetTrackUrl calls the artwork_gettrackurl host function.
|
||||
@ -174,7 +174,7 @@ func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, err
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, error) {
|
||||
func ArtworkGetTrackUrl(id string, size int32) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := ArtworkGetTrackUrlRequest{
|
||||
Id: id,
|
||||
@ -182,7 +182,7 @@ func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, err
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -197,15 +197,15 @@ func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, err
|
||||
// Parse the response
|
||||
var response ArtworkGetTrackUrlResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Url, nil
|
||||
}
|
||||
|
||||
// ArtworkGetPlaylistUrl calls the artwork_getplaylisturl host function.
|
||||
@ -216,7 +216,7 @@ func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, err
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetPlaylistUrl(id string, size int32) (*ArtworkGetPlaylistUrlResponse, error) {
|
||||
func ArtworkGetPlaylistUrl(id string, size int32) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := ArtworkGetPlaylistUrlRequest{
|
||||
Id: id,
|
||||
@ -224,7 +224,7 @@ func ArtworkGetPlaylistUrl(id string, size int32) (*ArtworkGetPlaylistUrlRespons
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -239,13 +239,13 @@ func ArtworkGetPlaylistUrl(id string, size int32) (*ArtworkGetPlaylistUrlRespons
|
||||
// Parse the response
|
||||
var response ArtworkGetPlaylistUrlResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Url, nil
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ type ArtworkGetPlaylistUrlResponse struct {
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, error) {
|
||||
func ArtworkGetArtistUrl(id string, size int32) (string, error) {
|
||||
panic("host: ArtworkGetArtistUrl is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func ArtworkGetArtistUrl(id string, size int32) (*ArtworkGetArtistUrlResponse, e
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, error) {
|
||||
func ArtworkGetAlbumUrl(id string, size int32) (string, error) {
|
||||
panic("host: ArtworkGetAlbumUrl is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ func ArtworkGetAlbumUrl(id string, size int32) (*ArtworkGetAlbumUrlResponse, err
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, error) {
|
||||
func ArtworkGetTrackUrl(id string, size int32) (string, error) {
|
||||
panic("host: ArtworkGetTrackUrl is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -100,6 +100,6 @@ func ArtworkGetTrackUrl(id string, size int32) (*ArtworkGetTrackUrlResponse, err
|
||||
// - size: Desired image size in pixels (0 for original size)
|
||||
//
|
||||
// Returns the public URL for the artwork, or an error if generation fails.
|
||||
func ArtworkGetPlaylistUrl(id string, size int32) (*ArtworkGetPlaylistUrlResponse, error) {
|
||||
func ArtworkGetPlaylistUrl(id string, size int32) (string, error) {
|
||||
panic("host: ArtworkGetPlaylistUrl is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -207,14 +207,14 @@ func CacheSetString(key string, value string, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a string, exists will be false.
|
||||
func CacheGetString(key string) (*CacheGetStringResponse, error) {
|
||||
func CacheGetString(key string) (string, bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := CacheGetStringRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -229,15 +229,15 @@ func CacheGetString(key string) (*CacheGetStringResponse, error) {
|
||||
// Parse the response
|
||||
var response CacheGetStringResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, response.Exists, nil
|
||||
}
|
||||
|
||||
// CacheSetInt calls the cache_setint host function.
|
||||
@ -291,14 +291,14 @@ func CacheSetInt(key string, value int64, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not an integer, exists will be false.
|
||||
func CacheGetInt(key string) (*CacheGetIntResponse, error) {
|
||||
func CacheGetInt(key string) (int64, bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := CacheGetIntRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -313,15 +313,15 @@ func CacheGetInt(key string) (*CacheGetIntResponse, error) {
|
||||
// Parse the response
|
||||
var response CacheGetIntResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0, false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return 0, false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, response.Exists, nil
|
||||
}
|
||||
|
||||
// CacheSetFloat calls the cache_setfloat host function.
|
||||
@ -375,14 +375,14 @@ func CacheSetFloat(key string, value float64, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a float, exists will be false.
|
||||
func CacheGetFloat(key string) (*CacheGetFloatResponse, error) {
|
||||
func CacheGetFloat(key string) (float64, bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := CacheGetFloatRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return 0, false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -397,15 +397,15 @@ func CacheGetFloat(key string) (*CacheGetFloatResponse, error) {
|
||||
// Parse the response
|
||||
var response CacheGetFloatResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0, false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return 0, false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, response.Exists, nil
|
||||
}
|
||||
|
||||
// CacheSetBytes calls the cache_setbytes host function.
|
||||
@ -459,14 +459,14 @@ func CacheSetBytes(key string, value []byte, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a byte slice, exists will be false.
|
||||
func CacheGetBytes(key string) (*CacheGetBytesResponse, error) {
|
||||
func CacheGetBytes(key string) ([]byte, bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := CacheGetBytesRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -481,15 +481,15 @@ func CacheGetBytes(key string) (*CacheGetBytesResponse, error) {
|
||||
// Parse the response
|
||||
var response CacheGetBytesResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return nil, false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, response.Exists, nil
|
||||
}
|
||||
|
||||
// CacheHas calls the cache_has host function.
|
||||
@ -499,14 +499,14 @@ func CacheGetBytes(key string) (*CacheGetBytesResponse, error) {
|
||||
// - key: The cache key (will be namespaced with plugin ID)
|
||||
//
|
||||
// Returns true if the key exists and has not expired.
|
||||
func CacheHas(key string) (*CacheHasResponse, error) {
|
||||
func CacheHas(key string) (bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := CacheHasRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -521,15 +521,15 @@ func CacheHas(key string) (*CacheHasResponse, error) {
|
||||
// Parse the response
|
||||
var response CacheHasResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Exists, nil
|
||||
}
|
||||
|
||||
// CacheRemove calls the cache_remove host function.
|
||||
|
||||
@ -121,7 +121,7 @@ func CacheSetString(key string, value string, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a string, exists will be false.
|
||||
func CacheGetString(key string) (*CacheGetStringResponse, error) {
|
||||
func CacheGetString(key string) (string, bool, error) {
|
||||
panic("host: CacheGetString is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ func CacheSetInt(key string, value int64, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not an integer, exists will be false.
|
||||
func CacheGetInt(key string) (*CacheGetIntResponse, error) {
|
||||
func CacheGetInt(key string) (int64, bool, error) {
|
||||
panic("host: CacheGetInt is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ func CacheSetFloat(key string, value float64, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a float, exists will be false.
|
||||
func CacheGetFloat(key string) (*CacheGetFloatResponse, error) {
|
||||
func CacheGetFloat(key string) (float64, bool, error) {
|
||||
panic("host: CacheGetFloat is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ func CacheSetBytes(key string, value []byte, ttlSeconds int64) error {
|
||||
//
|
||||
// Returns the value and whether the key exists. If the key doesn't exist
|
||||
// or the stored value is not a byte slice, exists will be false.
|
||||
func CacheGetBytes(key string) (*CacheGetBytesResponse, error) {
|
||||
func CacheGetBytes(key string) ([]byte, bool, error) {
|
||||
panic("host: CacheGetBytes is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ func CacheGetBytes(key string) (*CacheGetBytesResponse, error) {
|
||||
// - key: The cache key (will be namespaced with plugin ID)
|
||||
//
|
||||
// Returns true if the key exists and has not expired.
|
||||
func CacheHas(key string) (*CacheHasResponse, error) {
|
||||
func CacheHas(key string) (bool, error) {
|
||||
panic("host: CacheHas is only available in WASM plugins")
|
||||
}
|
||||
|
||||
|
||||
@ -143,14 +143,14 @@ func KVStoreSet(key string, value []byte) error {
|
||||
// - key: The storage key
|
||||
//
|
||||
// Returns the value and whether the key exists.
|
||||
func KVStoreGet(key string) (*KVStoreGetResponse, error) {
|
||||
func KVStoreGet(key string) ([]byte, bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := KVStoreGetRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -165,15 +165,15 @@ func KVStoreGet(key string) (*KVStoreGetResponse, error) {
|
||||
// Parse the response
|
||||
var response KVStoreGetResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return nil, false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Value, response.Exists, nil
|
||||
}
|
||||
|
||||
// KVStoreDelete calls the kvstore_delete host function.
|
||||
@ -222,14 +222,14 @@ func KVStoreDelete(key string) error {
|
||||
// - key: The storage key
|
||||
//
|
||||
// Returns true if the key exists.
|
||||
func KVStoreHas(key string) (*KVStoreHasResponse, error) {
|
||||
func KVStoreHas(key string) (bool, error) {
|
||||
// Marshal request to JSON
|
||||
req := KVStoreHasRequest{
|
||||
Key: key,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return false, err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -244,15 +244,15 @@ func KVStoreHas(key string) (*KVStoreHasResponse, error) {
|
||||
// Parse the response
|
||||
var response KVStoreHasResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return false, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Exists, nil
|
||||
}
|
||||
|
||||
// KVStoreList calls the kvstore_list host function.
|
||||
@ -262,7 +262,7 @@ func KVStoreHas(key string) (*KVStoreHasResponse, error) {
|
||||
// - prefix: Key prefix to filter by (empty string returns all keys)
|
||||
//
|
||||
// Returns a slice of matching keys.
|
||||
func KVStoreList(prefix string) (*KVStoreListResponse, error) {
|
||||
func KVStoreList(prefix string) ([]string, error) {
|
||||
// Marshal request to JSON
|
||||
req := KVStoreListRequest{
|
||||
Prefix: prefix,
|
||||
@ -292,12 +292,12 @@ func KVStoreList(prefix string) (*KVStoreListResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Keys, nil
|
||||
}
|
||||
|
||||
// KVStoreGetStorageUsed calls the kvstore_getstorageused host function.
|
||||
// GetStorageUsed returns the total storage used by this plugin in bytes.
|
||||
func KVStoreGetStorageUsed() (*KVStoreGetStorageUsedResponse, error) {
|
||||
func KVStoreGetStorageUsed() (int64, error) {
|
||||
// No parameters - allocate empty JSON object
|
||||
reqMem := pdk.AllocateBytes([]byte("{}"))
|
||||
defer reqMem.Free()
|
||||
@ -312,13 +312,13 @@ func KVStoreGetStorageUsed() (*KVStoreGetStorageUsedResponse, error) {
|
||||
// Parse the response
|
||||
var response KVStoreGetStorageUsedResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return 0, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Bytes, nil
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ func KVStoreSet(key string, value []byte) error {
|
||||
// - key: The storage key
|
||||
//
|
||||
// Returns the value and whether the key exists.
|
||||
func KVStoreGet(key string) (*KVStoreGetResponse, error) {
|
||||
func KVStoreGet(key string) ([]byte, bool, error) {
|
||||
panic("host: KVStoreGet is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ func KVStoreDelete(key string) error {
|
||||
// - key: The storage key
|
||||
//
|
||||
// Returns true if the key exists.
|
||||
func KVStoreHas(key string) (*KVStoreHasResponse, error) {
|
||||
func KVStoreHas(key string) (bool, error) {
|
||||
panic("host: KVStoreHas is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -111,12 +111,12 @@ func KVStoreHas(key string) (*KVStoreHasResponse, error) {
|
||||
// - prefix: Key prefix to filter by (empty string returns all keys)
|
||||
//
|
||||
// Returns a slice of matching keys.
|
||||
func KVStoreList(prefix string) (*KVStoreListResponse, error) {
|
||||
func KVStoreList(prefix string) ([]string, error) {
|
||||
panic("host: KVStoreList is only available in WASM plugins")
|
||||
}
|
||||
|
||||
// KVStoreGetStorageUsed is a stub that panics on non-WASM platforms.
|
||||
// GetStorageUsed returns the total storage used by this plugin in bytes.
|
||||
func KVStoreGetStorageUsed() (*KVStoreGetStorageUsedResponse, error) {
|
||||
func KVStoreGetStorageUsed() (int64, error) {
|
||||
panic("host: KVStoreGetStorageUsed is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ type LibraryGetAllLibrariesResponse struct {
|
||||
// - id: The library's unique identifier
|
||||
//
|
||||
// Returns the library metadata, or an error if the library is not found.
|
||||
func LibraryGetLibrary(id int32) (*LibraryGetLibraryResponse, error) {
|
||||
func LibraryGetLibrary(id int32) (*Library, error) {
|
||||
// Marshal request to JSON
|
||||
req := LibraryGetLibraryRequest{
|
||||
Id: id,
|
||||
@ -93,14 +93,14 @@ func LibraryGetLibrary(id int32) (*LibraryGetLibraryResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
// LibraryGetAllLibraries calls the library_getalllibraries host function.
|
||||
// GetAllLibraries retrieves metadata for all configured libraries.
|
||||
//
|
||||
// Returns a slice of all libraries with their metadata.
|
||||
func LibraryGetAllLibraries() (*LibraryGetAllLibrariesResponse, error) {
|
||||
func LibraryGetAllLibraries() ([]Library, error) {
|
||||
// No parameters - allocate empty JSON object
|
||||
reqMem := pdk.AllocateBytes([]byte("{}"))
|
||||
defer reqMem.Free()
|
||||
@ -123,5 +123,5 @@ func LibraryGetAllLibraries() (*LibraryGetAllLibrariesResponse, error) {
|
||||
return nil, errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ type LibraryGetAllLibrariesResponse struct {
|
||||
// - id: The library's unique identifier
|
||||
//
|
||||
// Returns the library metadata, or an error if the library is not found.
|
||||
func LibraryGetLibrary(id int32) (*LibraryGetLibraryResponse, error) {
|
||||
func LibraryGetLibrary(id int32) (*Library, error) {
|
||||
panic("host: LibraryGetLibrary is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -55,6 +55,6 @@ func LibraryGetLibrary(id int32) (*LibraryGetLibraryResponse, error) {
|
||||
// GetAllLibraries retrieves metadata for all configured libraries.
|
||||
//
|
||||
// Returns a slice of all libraries with their metadata.
|
||||
func LibraryGetAllLibraries() (*LibraryGetAllLibrariesResponse, error) {
|
||||
func LibraryGetAllLibraries() ([]Library, error) {
|
||||
panic("host: LibraryGetAllLibraries is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ type SchedulerCancelScheduleRequest struct {
|
||||
// - scheduleID: Optional unique identifier for the scheduled job. If empty, one will be generated
|
||||
//
|
||||
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
|
||||
func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID string) (*SchedulerScheduleOneTimeResponse, error) {
|
||||
func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID string) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := SchedulerScheduleOneTimeRequest{
|
||||
DelaySeconds: delaySeconds,
|
||||
@ -79,7 +79,7 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -94,15 +94,15 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
|
||||
// Parse the response
|
||||
var response SchedulerScheduleOneTimeResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.NewScheduleID, nil
|
||||
}
|
||||
|
||||
// SchedulerScheduleRecurring calls the scheduler_schedulerecurring host function.
|
||||
@ -115,7 +115,7 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
|
||||
// - scheduleID: Optional unique identifier for the scheduled job. If empty, one will be generated
|
||||
//
|
||||
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
|
||||
func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleID string) (*SchedulerScheduleRecurringResponse, error) {
|
||||
func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleID string) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := SchedulerScheduleRecurringRequest{
|
||||
CronExpression: cronExpression,
|
||||
@ -124,7 +124,7 @@ func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleI
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -139,15 +139,15 @@ func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleI
|
||||
// Parse the response
|
||||
var response SchedulerScheduleRecurringResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.NewScheduleID, nil
|
||||
}
|
||||
|
||||
// SchedulerCancelSchedule calls the scheduler_cancelschedule host function.
|
||||
|
||||
@ -49,7 +49,7 @@ type SchedulerCancelScheduleRequest struct {
|
||||
// - scheduleID: Optional unique identifier for the scheduled job. If empty, one will be generated
|
||||
//
|
||||
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
|
||||
func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID string) (*SchedulerScheduleOneTimeResponse, error) {
|
||||
func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID string) (string, error) {
|
||||
panic("host: SchedulerScheduleOneTime is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
|
||||
// - scheduleID: Optional unique identifier for the scheduled job. If empty, one will be generated
|
||||
//
|
||||
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
|
||||
func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleID string) (*SchedulerScheduleRecurringResponse, error) {
|
||||
func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleID string) (string, error) {
|
||||
panic("host: SchedulerScheduleRecurring is only available in WASM plugins")
|
||||
}
|
||||
|
||||
|
||||
@ -35,14 +35,14 @@ type SubsonicAPICallResponse struct {
|
||||
//
|
||||
// The uri parameter should be the Subsonic API path without the server prefix,
|
||||
// e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON.
|
||||
func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) {
|
||||
func SubsonicAPICall(uri string) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := SubsonicAPICallRequest{
|
||||
Uri: uri,
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -57,13 +57,13 @@ func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) {
|
||||
// Parse the response
|
||||
var response SubsonicAPICallResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.ResponseJSON, nil
|
||||
}
|
||||
|
||||
@ -24,6 +24,6 @@ type SubsonicAPICallResponse struct {
|
||||
//
|
||||
// The uri parameter should be the Subsonic API path without the server prefix,
|
||||
// e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON.
|
||||
func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) {
|
||||
func SubsonicAPICall(uri string) (string, error) {
|
||||
panic("host: SubsonicAPICall is only available in WASM plugins")
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ type WebSocketCloseConnectionRequest struct {
|
||||
//
|
||||
// Returns the connection ID that can be used to send messages or close the connection,
|
||||
// or an error if the connection fails.
|
||||
func WebSocketConnect(url string, headers map[string]string, connectionID string) (*WebSocketConnectResponse, error) {
|
||||
func WebSocketConnect(url string, headers map[string]string, connectionID string) (string, error) {
|
||||
// Marshal request to JSON
|
||||
req := WebSocketConnectRequest{
|
||||
Url: url,
|
||||
@ -88,7 +88,7 @@ func WebSocketConnect(url string, headers map[string]string, connectionID string
|
||||
}
|
||||
reqBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
reqMem := pdk.AllocateBytes(reqBytes)
|
||||
defer reqMem.Free()
|
||||
@ -103,15 +103,15 @@ func WebSocketConnect(url string, headers map[string]string, connectionID string
|
||||
// Parse the response
|
||||
var response WebSocketConnectResponse
|
||||
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Convert Error field to Go error
|
||||
if response.Error != "" {
|
||||
return nil, errors.New(response.Error)
|
||||
return "", errors.New(response.Error)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
return response.NewConnectionID, nil
|
||||
}
|
||||
|
||||
// WebSocketSendText calls the websocket_sendtext host function.
|
||||
|
||||
@ -53,7 +53,7 @@ type WebSocketCloseConnectionRequest struct {
|
||||
//
|
||||
// Returns the connection ID that can be used to send messages or close the connection,
|
||||
// or an error if the connection fails.
|
||||
func WebSocketConnect(url string, headers map[string]string, connectionID string) (*WebSocketConnectResponse, error) {
|
||||
func WebSocketConnect(url string, headers map[string]string, connectionID string) (string, error) {
|
||||
panic("host: WebSocketConnect is only available in WASM plugins")
|
||||
}
|
||||
|
||||
|
||||
28
plugins/testdata/test-artwork/main.go
vendored
28
plugins/testdata/test-artwork/main.go
vendored
@ -38,33 +38,13 @@ func ndTestArtwork() int32 {
|
||||
|
||||
switch strings.ToLower(input.ArtworkType) {
|
||||
case "artist":
|
||||
resp, e := host.ArtworkGetArtistUrl(input.ID, input.Size)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else {
|
||||
url = resp.Url
|
||||
}
|
||||
url, err = host.ArtworkGetArtistUrl(input.ID, input.Size)
|
||||
case "album":
|
||||
resp, e := host.ArtworkGetAlbumUrl(input.ID, input.Size)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else {
|
||||
url = resp.Url
|
||||
}
|
||||
url, err = host.ArtworkGetAlbumUrl(input.ID, input.Size)
|
||||
case "track":
|
||||
resp, e := host.ArtworkGetTrackUrl(input.ID, input.Size)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else {
|
||||
url = resp.Url
|
||||
}
|
||||
url, err = host.ArtworkGetTrackUrl(input.ID, input.Size)
|
||||
case "playlist":
|
||||
resp, e := host.ArtworkGetPlaylistUrl(input.ID, input.Size)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else {
|
||||
url = resp.Url
|
||||
}
|
||||
url, err = host.ArtworkGetPlaylistUrl(input.ID, input.Size)
|
||||
default:
|
||||
errStr := "unknown artwork type: " + input.ArtworkType
|
||||
pdk.OutputJSON(TestOutput{Error: &errStr})
|
||||
|
||||
20
plugins/testdata/test-cache-plugin/main.go
vendored
20
plugins/testdata/test-cache-plugin/main.go
vendored
@ -51,13 +51,13 @@ func ndTestCache() int32 {
|
||||
return 0
|
||||
|
||||
case "get_string":
|
||||
resp, err := host.CacheGetString(input.Key)
|
||||
value, exists, err := host.CacheGetString(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestCacheOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestCacheOutput{StringVal: resp.Value, Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestCacheOutput{StringVal: value, Exists: exists})
|
||||
return 0
|
||||
|
||||
case "set_int":
|
||||
@ -71,13 +71,13 @@ func ndTestCache() int32 {
|
||||
return 0
|
||||
|
||||
case "get_int":
|
||||
resp, err := host.CacheGetInt(input.Key)
|
||||
value, exists, err := host.CacheGetInt(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestCacheOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestCacheOutput{IntVal: resp.Value, Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestCacheOutput{IntVal: value, Exists: exists})
|
||||
return 0
|
||||
|
||||
case "set_float":
|
||||
@ -91,13 +91,13 @@ func ndTestCache() int32 {
|
||||
return 0
|
||||
|
||||
case "get_float":
|
||||
resp, err := host.CacheGetFloat(input.Key)
|
||||
value, exists, err := host.CacheGetFloat(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestCacheOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestCacheOutput{FloatVal: resp.Value, Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestCacheOutput{FloatVal: value, Exists: exists})
|
||||
return 0
|
||||
|
||||
case "set_bytes":
|
||||
@ -111,23 +111,23 @@ func ndTestCache() int32 {
|
||||
return 0
|
||||
|
||||
case "get_bytes":
|
||||
resp, err := host.CacheGetBytes(input.Key)
|
||||
value, exists, err := host.CacheGetBytes(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestCacheOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestCacheOutput{BytesVal: resp.Value, Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestCacheOutput{BytesVal: value, Exists: exists})
|
||||
return 0
|
||||
|
||||
case "has":
|
||||
resp, err := host.CacheHas(input.Key)
|
||||
exists, err := host.CacheHas(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestCacheOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestCacheOutput{Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestCacheOutput{Exists: exists})
|
||||
return 0
|
||||
|
||||
case "remove":
|
||||
|
||||
16
plugins/testdata/test-kvstore/main.go
vendored
16
plugins/testdata/test-kvstore/main.go
vendored
@ -47,13 +47,13 @@ func ndTestKVStore() int32 {
|
||||
return 0
|
||||
|
||||
case "get":
|
||||
resp, err := host.KVStoreGet(input.Key)
|
||||
value, exists, err := host.KVStoreGet(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestKVStoreOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestKVStoreOutput{Value: resp.Value, Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestKVStoreOutput{Value: value, Exists: exists})
|
||||
return 0
|
||||
|
||||
case "delete":
|
||||
@ -67,33 +67,33 @@ func ndTestKVStore() int32 {
|
||||
return 0
|
||||
|
||||
case "has":
|
||||
resp, err := host.KVStoreHas(input.Key)
|
||||
exists, err := host.KVStoreHas(input.Key)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestKVStoreOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestKVStoreOutput{Exists: resp.Exists})
|
||||
pdk.OutputJSON(TestKVStoreOutput{Exists: exists})
|
||||
return 0
|
||||
|
||||
case "list":
|
||||
resp, err := host.KVStoreList(input.Prefix)
|
||||
keys, err := host.KVStoreList(input.Prefix)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestKVStoreOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestKVStoreOutput{Keys: resp.Keys})
|
||||
pdk.OutputJSON(TestKVStoreOutput{Keys: keys})
|
||||
return 0
|
||||
|
||||
case "get_storage_used":
|
||||
resp, err := host.KVStoreGetStorageUsed()
|
||||
bytesUsed, err := host.KVStoreGetStorageUsed()
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestKVStoreOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestKVStoreOutput{StorageUsed: resp.Bytes})
|
||||
pdk.OutputJSON(TestKVStoreOutput{StorageUsed: bytesUsed})
|
||||
return 0
|
||||
|
||||
default:
|
||||
|
||||
8
plugins/testdata/test-library/main.go
vendored
8
plugins/testdata/test-library/main.go
vendored
@ -42,23 +42,23 @@ func ndTestLibrary() int32 {
|
||||
|
||||
switch input.Operation {
|
||||
case "get_library":
|
||||
resp, err := host.LibraryGetLibrary(input.LibraryID)
|
||||
library, err := host.LibraryGetLibrary(input.LibraryID)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestLibraryOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestLibraryOutput{Library: resp.Result})
|
||||
pdk.OutputJSON(TestLibraryOutput{Library: library})
|
||||
return 0
|
||||
|
||||
case "get_all_libraries":
|
||||
resp, err := host.LibraryGetAllLibraries()
|
||||
libraries, err := host.LibraryGetAllLibraries()
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
pdk.OutputJSON(TestLibraryOutput{Error: &errStr})
|
||||
return 0
|
||||
}
|
||||
pdk.OutputJSON(TestLibraryOutput{Libraries: resp.Result})
|
||||
pdk.OutputJSON(TestLibraryOutput{Libraries: libraries})
|
||||
return 0
|
||||
|
||||
case "read_file":
|
||||
|
||||
@ -17,14 +17,14 @@ func callSubsonicAPIExport() int32 {
|
||||
uri := pdk.InputString()
|
||||
|
||||
// Call the Subsonic API via host function
|
||||
response, err := host.SubsonicAPICall(uri)
|
||||
responseJSON, err := host.SubsonicAPICall(uri)
|
||||
if err != nil {
|
||||
pdk.SetErrorString("failed to call SubsonicAPI: " + err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
// Return the response
|
||||
pdk.OutputString(response.ResponseJSON)
|
||||
pdk.OutputString(responseJSON)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user