-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BREAKING] Tasks Parity #425
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8fe2855
Improve Type Safety around Tasks
Sherlouk 1c8756e
Add cancel and delete tasks public APIs
Sherlouk cc8bb7d
Safely Throw Errors in Tests
Sherlouk 2dd2fce
Add Integration Tests for New APIs
Sherlouk 9dce221
Use Types instead of Strings for Task Queries
Sherlouk aeb6f44
Update Tests after Rebase
Sherlouk 41d7976
Improve Resilience of Delete Test
Sherlouk f10885c
Update Code Samples
Sherlouk 4bcee63
Apply fix for unit test
Sherlouk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 was deleted.
Oops, something went wrong.
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,65 @@ | ||
import Foundation | ||
|
||
/** | ||
`Task` instances represent the current transaction status, use the `uid` value to | ||
verify the status of your transaction. | ||
*/ | ||
public struct Task: Decodable, Equatable { | ||
/// Unique ID for the current `Task`. | ||
public let uid: Int | ||
|
||
/// Unique identifier of the targeted index | ||
public let indexUid: String? | ||
|
||
/// Returns if the task has been successful or not. | ||
public let status: Status | ||
|
||
/// Type of the task. | ||
public let type: TaskType | ||
|
||
/// Details of the task. | ||
public let details: Details? | ||
|
||
/// Duration of the task process. | ||
public let duration: String? | ||
|
||
/// Date when the task has been enqueued. | ||
public let enqueuedAt: Date | ||
|
||
/// Date when the task has been started. | ||
public let startedAt: Date? | ||
|
||
/// Date when the task has been finished, regardless of status. | ||
public let finishedAt: Date? | ||
|
||
/// ID of the the `Task` which caused this to be canceled. | ||
public let canceledBy: Int? | ||
|
||
/// Error information in case of failed update. | ||
public let error: MeiliSearch.MSErrorResponse? | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let type = try container.decode(TaskType.self, forKey: .type) | ||
|
||
self.uid = try container.decode(Int.self, forKey: .uid) | ||
self.indexUid = try container.decodeIfPresent(String.self, forKey: .indexUid) | ||
self.status = try container.decode(Status.self, forKey: .status) | ||
self.type = type | ||
self.duration = try container.decodeIfPresent(String.self, forKey: .duration) | ||
self.enqueuedAt = try container.decode(Date.self, forKey: .enqueuedAt) | ||
self.startedAt = try container.decodeIfPresent(Date.self, forKey: .startedAt) | ||
self.finishedAt = try container.decodeIfPresent(Date.self, forKey: .finishedAt) | ||
self.canceledBy = try container.decodeIfPresent(Int.self, forKey: .canceledBy) | ||
self.error = try container.decodeIfPresent(MeiliSearch.MSErrorResponse.self, forKey: .error) | ||
|
||
// we ignore errors thrown by `superDecoder` to handle cases where no details are provided by the API | ||
// for example when the type is `snapshotCreation`. | ||
let detailsDecoder = try? container.superDecoder(forKey: .details) | ||
self.details = try Details(decoder: detailsDecoder, type: type) | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case uid, indexUid, status, type, details, duration, enqueuedAt, startedAt, finishedAt, canceledBy, error | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this PR breaking so?
Not an issue for me to break, we are not stable yet. It's to apply the right versioning and provide a clear changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, yes. The changes have been documented in the initial PR description, in case you want to copy them into a changelog 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, and looking at tickets in the backlog, I'm intentionally looking to prioritise breaking changes now in order to get us to a stable position quicker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's merge it with breaking then! thank you for the help of the changelog ❤️