summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-12-25 18:22:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-12-25 18:22:17 -0400
commit1b2db0599f76ff9504b6f4125876b4101d1ad4bb (patch)
tree168fa395f53245cd3dbc6831fcf8dff3a3a1245e /doc
parentbb8aafddbe194db708b1e975289de9f361384eab (diff)
devblog
Diffstat (limited to 'doc')
-rw-r--r--doc/devblog/day_85__external_special_remote_protocol_types.mdwn25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/devblog/day_85__external_special_remote_protocol_types.mdwn b/doc/devblog/day_85__external_special_remote_protocol_types.mdwn
new file mode 100644
index 000000000..f8d7f4270
--- /dev/null
+++ b/doc/devblog/day_85__external_special_remote_protocol_types.mdwn
@@ -0,0 +1,25 @@
+Only did a few hours today, getting started on implementing the
+[[design/external_special_remote_protocol]].
+
+Mostly this involved writing down types for the various messages,
+and code to parse them. I'm very happy with how the parsing turned out;
+nearly all the work is handled by the data types and type classes,
+and so only one line of very simple code is needed to parse each message:
+
+[[!format haskell """
+instance Receivable Response where
+ parseCommand "PREPARE-SUCCESS" = parse0 PREPARE_SUCCESS
+ parseCommand "TRANSFER-SUCCESS" = parse2 TRANSFER_SUCCESS
+ parseCommand "TRANSFER-FAILURE" = parse3 TRANSFER_FAILURE
+"""]]]
+
+An especially nice part of this implementation is that it knows exactly how
+many parameters each message should have (and their types of course), and so
+can both reject invalid messages, and avoid ambiguity in tokenizing the
+parameters. For example, the 3rd parameter of TRANSFER-FAILURE is an error
+message, and as it's the last parameter, it can contain multiple words.
+
+ *Remote.External> parseMessage "TRANSFER-FAILURE STORE SHA1--foo doesn't work on Christmas" :: Maybe Response
+ Just (TRANSFER_FAILURE Upload (Key {keyName = "foo", keyBackendName = "SHA1", keySize = Nothing, keyMtime = Nothing}) "doesn't work on Christmas")
+
+That's the easy groundwork for external special remotes, done.