-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from tombuildsstuff/pollers
Add pollers for `CopyAndWait` in `file/files` and `blobs/blob`
- Loading branch information
Showing
23 changed files
with
250 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package blobs | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers" | ||
) | ||
|
||
var _ pollers.PollerType = ©AndWaitPoller{} | ||
|
||
func NewCopyAndWaitPoller(client *Client, containerName, blobName string, getPropertiesInput GetPropertiesInput) *copyAndWaitPoller { | ||
return ©AndWaitPoller{ | ||
client: client, | ||
containerName: containerName, | ||
blobName: blobName, | ||
getPropertiesInput: getPropertiesInput, | ||
} | ||
} | ||
|
||
type copyAndWaitPoller struct { | ||
client *Client | ||
containerName string | ||
blobName string | ||
getPropertiesInput GetPropertiesInput | ||
} | ||
|
||
func (p *copyAndWaitPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { | ||
props, err := p.client.GetProperties(ctx, p.containerName, p.blobName, p.getPropertiesInput) | ||
if err != nil { | ||
return nil, fmt.Errorf("retrieving properties (container: %s blob: %s) : %+v", p.containerName, p.blobName, err) | ||
} | ||
|
||
if strings.EqualFold(string(props.CopyStatus), string(Success)) { | ||
return &pollers.PollResult{ | ||
Status: pollers.PollingStatusSucceeded, | ||
PollInterval: 10 * time.Second, | ||
}, nil | ||
} | ||
|
||
// Processing | ||
return &pollers.PollResult{ | ||
Status: pollers.PollingStatusInProgress, | ||
PollInterval: 10 * time.Second, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package files | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers" | ||
) | ||
|
||
var _ pollers.PollerType = ©AndWaitPoller{} | ||
|
||
func NewCopyAndWaitPoller(client *Client, shareName, path, fileName string) *copyAndWaitPoller { | ||
return ©AndWaitPoller{ | ||
client: client, | ||
shareName: shareName, | ||
path: path, | ||
fileName: fileName, | ||
} | ||
} | ||
|
||
type copyAndWaitPoller struct { | ||
client *Client | ||
shareName string | ||
path string | ||
fileName string | ||
} | ||
|
||
func (p *copyAndWaitPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { | ||
props, err := p.client.GetProperties(ctx, p.shareName, p.path, p.fileName) | ||
if err != nil { | ||
return nil, fmt.Errorf("retrieving copy (shareName: %s path: %s fileName: %s) : %+v", p.shareName, p.path, p.fileName, err) | ||
} | ||
|
||
if strings.EqualFold(props.CopyStatus, "success") { | ||
return &pollers.PollResult{ | ||
Status: pollers.PollingStatusSucceeded, | ||
PollInterval: 10 * time.Second, | ||
}, nil | ||
} | ||
|
||
// Processing | ||
return &pollers.PollResult{ | ||
Status: pollers.PollingStatusInProgress, | ||
PollInterval: 10 * time.Second, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.