Skip to content
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

Make ethernet and cellular clients more robust against cancelation #2074

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions external/gold/toit-supabase__examples__auth_email.toit.gold

This file was deleted.

30 changes: 0 additions & 30 deletions external/gold/toit-supabase__examples__auth_oauth.toit.gold

This file was deleted.

30 changes: 0 additions & 30 deletions external/gold/toit-supabase__examples__rest.toit.gold

This file was deleted.

30 changes: 0 additions & 30 deletions external/gold/toit-supabase__examples__storage.toit.gold

This file was deleted.

30 changes: 0 additions & 30 deletions external/gold/toit-supabase__examples__utils__client.toit.gold

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions external/gold/toit-supabase__src__auth.toit.gold

This file was deleted.

18 changes: 0 additions & 18 deletions external/gold/toit-supabase__src__filter.toit.gold

This file was deleted.

18 changes: 0 additions & 18 deletions external/gold/toit-supabase__src__supabase.toit.gold

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 19 additions & 1 deletion lib/net/cellular.toit
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,28 @@ open config/Map? -> net.Client
// generalize this handling for net.open and wifi.open too,
// so we get a shared pattern for dealing with discovering
// such network services at start up.
service-initialized_ = true
service_ = (CellularServiceClient).open
--timeout=(Duration --s=5)
--if-absent=: null
// If opening the client failed due to exceptions or
// cancelation, we will try again next time $open is
// called. If the service was just absent even after
// having waited for it to appear, we will not try
// again unless $reset has been called in between.
service-initialized_ = true
service := service_
if not service: throw "cellular unavailable"
return net.Client service --name=name (service.connect config)

/**
Resets the cellular client.

This allows re-establishing the link to the cellular service
provider at a later time. At that point, the service provider
may have changed, so calling $reset enables reacting to that.
*/
reset -> none:
service := service_
service_ = null
service-initialized_ = false
if service: service.close
20 changes: 19 additions & 1 deletion lib/net/ethernet.toit
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,28 @@ open --name/string?=null -> net.Client:
// generalize this handling for net.open and wifi.open too,
// so we get a shared pattern for dealing with discovering
// such network services at start up.
service-initialized_ = true
service_ = (EthernetServiceClient).open
--timeout=(Duration --s=5)
--if-absent=: null
// If opening the client failed due to exceptions or
// cancelation, we will try again next time $open is
// called. If the service was just absent even after
// having waited for it to appear, we will not try
// again unless $reset has been called in between.
service-initialized_ = true
service := service_
if not service: throw "ethernet unavailable"
return net.Client service --name=name service.connect

/**
Resets the ethernet client.

This allows re-establishing the link to the ethernet service
provider at a later time. At that point, the service provider
may have changed, so calling $reset enables reacting to that.
*/
reset -> none:
service := service_
service_ = null
service-initialized_ = false
if service: service.close
Loading