go client: augment return types with pre-processed KSUIDs
Docker server image / build-and-push (push) Successful in 3m11s
Docker server image / build-and-push (push) Successful in 3m11s
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"connectrpc.com/connect"
|
||||
"github.com/segmentio/ksuid"
|
||||
officeconvertapiv1 "gitea.auvem.com/end-internal/officeconvert/gen/go/officeconvertapi/v1"
|
||||
"gitea.auvem.com/end-internal/officeconvert/gen/go/officeconvertapi/v1/officeconvertapiv1connect"
|
||||
)
|
||||
@@ -47,7 +48,7 @@ func (c *Client) CreateConversion(
|
||||
ctx context.Context,
|
||||
sourceFilename string,
|
||||
resolution officeconvertapiv1.ConversionResolution,
|
||||
) (*officeconvertapiv1.CreateConversionResponse, error) {
|
||||
) (*CreateConversionResponse, error) {
|
||||
req := connect.NewRequest(&officeconvertapiv1.CreateConversionRequest{
|
||||
SourceFilename: sourceFilename,
|
||||
Resolution: resolution,
|
||||
@@ -56,46 +57,46 @@ func (c *Client) CreateConversion(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Msg, nil
|
||||
return augmentCreateConversionResponse(res.Msg)
|
||||
}
|
||||
|
||||
// StartConversion signals that upload is complete and conversion can begin.
|
||||
func (c *Client) StartConversion(
|
||||
ctx context.Context,
|
||||
conversionID string,
|
||||
) (*officeconvertapiv1.StartConversionResponse, error) {
|
||||
id ksuid.KSUID,
|
||||
) (*StartConversionResponse, error) {
|
||||
req := connect.NewRequest(&officeconvertapiv1.StartConversionRequest{
|
||||
ConversionId: conversionID,
|
||||
ConversionId: id.String(),
|
||||
})
|
||||
res, err := c.rpc.StartConversion(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Msg, nil
|
||||
return augmentStartConversionResponse(res.Msg)
|
||||
}
|
||||
|
||||
// GetConversionStatus returns the latest status for a conversion session.
|
||||
func (c *Client) GetConversionStatus(
|
||||
ctx context.Context,
|
||||
conversionID string,
|
||||
) (*officeconvertapiv1.GetConversionStatusResponse, error) {
|
||||
id ksuid.KSUID,
|
||||
) (*GetConversionStatusResponse, error) {
|
||||
req := connect.NewRequest(&officeconvertapiv1.GetConversionStatusRequest{
|
||||
ConversionId: conversionID,
|
||||
ConversionId: id.String(),
|
||||
})
|
||||
res, err := c.rpc.GetConversionStatus(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Msg, nil
|
||||
return augmentGetConversionStatusResponse(res.Msg)
|
||||
}
|
||||
|
||||
// GetSlideDeck retrieves the final converted deck response.
|
||||
func (c *Client) GetSlideDeck(
|
||||
ctx context.Context,
|
||||
conversionID string,
|
||||
id ksuid.KSUID,
|
||||
) (*officeconvertapiv1.GetSlideDeckResponse, error) {
|
||||
req := connect.NewRequest(&officeconvertapiv1.GetSlideDeckRequest{
|
||||
ConversionId: conversionID,
|
||||
ConversionId: id.String(),
|
||||
})
|
||||
res, err := c.rpc.GetSlideDeck(ctx, req)
|
||||
if err != nil {
|
||||
@@ -107,28 +108,28 @@ func (c *Client) GetSlideDeck(
|
||||
// DeleteConversion triggers immediate resource cleanup for a session.
|
||||
func (c *Client) DeleteConversion(
|
||||
ctx context.Context,
|
||||
conversionID string,
|
||||
) (*officeconvertapiv1.DeleteConversionResponse, error) {
|
||||
id ksuid.KSUID,
|
||||
) (*DeleteConversionResponse, error) {
|
||||
req := connect.NewRequest(&officeconvertapiv1.DeleteConversionRequest{
|
||||
ConversionId: conversionID,
|
||||
ConversionId: id.String(),
|
||||
})
|
||||
res, err := c.rpc.DeleteConversion(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Msg, nil
|
||||
return augmentDeleteConversionResponse(res.Msg)
|
||||
}
|
||||
|
||||
// WaitForCompletion polls status until terminal completion or context cancellation.
|
||||
func (c *Client) WaitForCompletion(
|
||||
ctx context.Context,
|
||||
conversionID string,
|
||||
) (*officeconvertapiv1.GetConversionStatusResponse, error) {
|
||||
id ksuid.KSUID,
|
||||
) (*GetConversionStatusResponse, error) {
|
||||
ticker := time.NewTicker(c.pollInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
status, err := c.GetConversionStatus(ctx, conversionID)
|
||||
status, err := c.GetConversionStatus(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user