-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the interface between elm app and web host
+ Remove redundant requests to be notified on the arrival of time. + Clarify there is no dependency between the different tasks, as outlined at https://github.com/elm-fullstack/elm-fullstack/blob/6fa473cd9a6287e1ef452a1d736d445330e79739/explore/2019-08-31.interface-between-process-and-host/2019-08-31.interface-between-process-and-host.md + For now, continue supporting the old interface. Implement a branch in the host to use the version of the interface matching the Elm app code. + Adapt enough examples in tests to cover the different messages on the new interface. + Update the names of JSON fields on the interface to use the consistent casing of the first letters. + Also in the new version of the interface Elm module: Adapt to recent observations of conversions between `Bytes.Bytes` and other representations: Use base64 for now because the conversions cost a lot of time with the current execution engine. As can be seen in some examples, we need to convert back to base64 again anyway.
- Loading branch information
Showing
12 changed files
with
396 additions
and
264 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
83 changes: 83 additions & 0 deletions
83
implement/PersistentProcess/PersistentProcess.Common/InterfaceToHost_Before_2020_06_20.cs
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,83 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Kalmit.PersistentProcess.InterfaceToHost_Before_2020_06_20 | ||
{ | ||
public class Event | ||
{ | ||
public InterfaceToHost.HttpRequestEvent httpRequest; | ||
|
||
public InterfaceToHost.ResultFromTaskWithId taskComplete; | ||
|
||
public InterfaceToHost.ArrivedAtTimeEventStructure ArrivedAtTimeEvent; | ||
|
||
static public Event FromAppEvent(InterfaceToHost.AppEventStructure appEvent) | ||
{ | ||
if (appEvent.ArrivedAtTimeEvent != null) | ||
return new Event { ArrivedAtTimeEvent = appEvent.ArrivedAtTimeEvent }; | ||
|
||
if (appEvent.TaskCompleteEvent != null) | ||
return new Event { taskComplete = appEvent.TaskCompleteEvent }; | ||
|
||
if (appEvent.HttpRequestEvent != null) | ||
return new Event { httpRequest = appEvent.HttpRequestEvent }; | ||
|
||
throw new NotImplementedException("Programming error: Case not implemented."); | ||
} | ||
|
||
public InterfaceToHost.AppEventStructure AsAppEvent() | ||
{ | ||
if (ArrivedAtTimeEvent != null) | ||
return new InterfaceToHost.AppEventStructure { ArrivedAtTimeEvent = ArrivedAtTimeEvent }; | ||
|
||
if (httpRequest != null) | ||
return new InterfaceToHost.AppEventStructure { HttpRequestEvent = httpRequest }; | ||
|
||
if (taskComplete != null) | ||
return new InterfaceToHost.AppEventStructure { TaskCompleteEvent = taskComplete }; | ||
|
||
throw new NotImplementedException("Programming error: Case not implemented."); | ||
} | ||
} | ||
|
||
public class ResponseOverSerialInterface | ||
{ | ||
public string decodeEventError; | ||
|
||
public ProcessRequest[] decodeEventSuccess; | ||
|
||
public InterfaceToHost.ResponseOverSerialInterface TranslateToNewStructure() | ||
{ | ||
if (decodeEventSuccess == null) | ||
return new InterfaceToHost.ResponseOverSerialInterface { DecodeEventError = decodeEventError }; | ||
|
||
var notifyWhenArrivedAtTime = | ||
decodeEventSuccess.Select(request => request.NotifyWhenArrivedAtTimeRequest).WhereNotNull().FirstOrDefault(); | ||
|
||
var startTasks = | ||
decodeEventSuccess.Select(request => request.startTask).WhereNotNull().ToArray(); | ||
|
||
var completeHttpResponses = | ||
decodeEventSuccess.Select(request => request.completeHttpResponse).WhereNotNull().ToArray(); | ||
|
||
return new InterfaceToHost.ResponseOverSerialInterface | ||
{ | ||
DecodeEventSuccess = new InterfaceToHost.AppEventResponseStructure | ||
{ | ||
startTasks = startTasks, | ||
completeHttpResponses = completeHttpResponses, | ||
notifyWhenArrivedAtTime = notifyWhenArrivedAtTime, | ||
} | ||
}; | ||
} | ||
} | ||
|
||
public class ProcessRequest | ||
{ | ||
public InterfaceToHost.HttpResponseRequest completeHttpResponse; | ||
|
||
public InterfaceToHost.StartTask startTask; | ||
|
||
public InterfaceToHost.NotifyWhenArrivedAtTimeRequestStructure NotifyWhenArrivedAtTimeRequest; | ||
} | ||
} |
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
Oops, something went wrong.