edge/pkg/module/cast/arcast/client.go
William Petit 7633ae0419
Some checks are pending
arcad/edge/pipeline/head Build started...
arcad/edge/pipeline/pr-master Build started...
feat(module): arcast integration
2024-01-12 14:02:53 +01:00

50 lines
977 B
Go

package arcast
import (
"context"
"forge.cadoles.com/arcad/arcast/pkg/client"
"forge.cadoles.com/arcad/edge/pkg/module/cast"
"github.com/pkg/errors"
)
type Client struct {
client *client.Client
addr string
}
// Close implements cast.Client.
func (c *Client) Close() error {
return nil
}
// Load implements cast.Client.
func (c *Client) Load(ctx context.Context, url string) error {
if _, err := c.client.Cast(ctx, c.addr, url); err != nil {
return errors.WithStack(err)
}
return nil
}
// Status implements cast.Client.
func (c *Client) Status(ctx context.Context) (cast.DeviceStatus, error) {
status, err := c.client.Status(ctx, c.addr)
if err != nil {
return nil, errors.WithStack(err)
}
return &DeviceStatus{status}, nil
}
// Unload implements cast.Client.
func (c *Client) Unload(ctx context.Context) error {
if _, err := c.client.Reset(ctx, c.addr); err != nil {
return errors.WithStack(err)
}
return nil
}
var _ cast.Client = &Client{}