-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closes #9291
- Loading branch information
Showing
17 changed files
with
722 additions
and
276 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
33 changes: 33 additions & 0 deletions
33
distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Cloud_Caching_Settings.enso
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,33 @@ | ||
import project.Data.Time.Duration.Duration | ||
import project.Enso_Cloud.Internal.Existing_Enso_Asset.Asset_Cache | ||
import project.Nothing.Nothing | ||
|
||
polyglot java import org.enso.base.enso_cloud.CacheSettings | ||
|
||
## PRIVATE | ||
UNSTABLE | ||
ADVANCED | ||
Sets for how long is Enso Cloud file information cached without checking for | ||
external updates. | ||
|
||
The default TTL is 60 seconds. | ||
|
||
Side effects from this Enso workflow will invalidate the cache immediately, | ||
but any external operations (done from other Enso instances) will not be | ||
visible until a cached value expires. Thus if the workflow is expected to | ||
co-operate with other workflows, it may be useful to decrease the cache TTL | ||
or disable it completely by passing `Nothing`. | ||
|
||
Note that completely disabling the caching will affect performance, as some | ||
generic operations may perform multiple cloud requests. | ||
|
||
Changing the TTL invalidates all existing cache entries, because their | ||
expiration time was calculated using the old TTL. | ||
set_file_cache_ttl (duration : Duration | Nothing) = | ||
CacheSettings.setFileCacheTTL duration | ||
Asset_Cache.invalidate_all | ||
|
||
## PRIVATE | ||
ADVANCED | ||
Returns the current file cache TTL. | ||
get_file_cache_ttl -> Duration | Nothing = CacheSettings.getFileCacheTTL |
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
34 changes: 34 additions & 0 deletions
34
...ibution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_File_Write_Strategy.enso
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,34 @@ | ||
private | ||
|
||
import project.Error.Error | ||
import project.Errors.Common.Forbidden_Operation | ||
import project.Errors.Unimplemented.Unimplemented | ||
import project.System.File.Existing_File_Behavior.Existing_File_Behavior | ||
import project.System.File.File | ||
from project.Data.Boolean import Boolean, False, True | ||
from project.Enso_Cloud.Enso_File import Enso_File, upload_file | ||
from project.System.File.Generic.File_Write_Strategy import default_append, default_overwrite, default_raise_error, File_Write_Strategy, generic_remote_write_with_local_file | ||
|
||
## PRIVATE | ||
In the Enso_File, we use the Overwrite strategy for Backup. | ||
That is because, the Cloud keeps versions of the file by itself, | ||
so there is no need to duplicate its work on our own - just overwriting the | ||
file still ensures we have a backup. | ||
instance = | ||
File_Write_Strategy.Value default_overwrite default_append default_raise_error write_backing_up=default_overwrite create_dry_run_file remote_write_with_local_file copy_from_local | ||
|
||
|
||
## PRIVATE | ||
create_dry_run_file file copy_original = | ||
_ = [file, copy_original] | ||
Error.throw (Forbidden_Operation.Error "Currently dry-run is not supported for Enso_File, so writing to an Enso_File is forbidden if the Output context is disabled.") | ||
|
||
|
||
## PRIVATE | ||
remote_write_with_local_file file existing_file_behavior action = | ||
if existing_file_behavior == Existing_File_Behavior.Append then Unimplemented.throw "Enso Cloud does not yet support appending to a file. Instead you may read it, modify and then write the new contents." else | ||
generic_remote_write_with_local_file file existing_file_behavior action | ||
|
||
## PRIVATE | ||
copy_from_local (source : File) (destination : Enso_File) (replace_existing : Boolean) = | ||
upload_file source destination replace_existing |
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.