Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311884

Change subject: [WIP] SourceFields experiment
......................................................................

[WIP] SourceFields experiment

Change-Id: I35a801b30a3d2565b1e4d4d1520ffc122d8c7574
---
A CrmLink/Messages/SourceFields.php
M SmashPig.yaml
2 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/84/311884/1

diff --git a/CrmLink/Messages/SourceFields.php 
b/CrmLink/Messages/SourceFields.php
new file mode 100644
index 0000000..32fddd7
--- /dev/null
+++ b/CrmLink/Messages/SourceFields.php
@@ -0,0 +1,23 @@
+<?php
+namespace SmashPig\CrmLink\Messages;
+
+class SourceFields {
+       /**
+        * Override source fields using configuration, e.g. for stamping 
outgoing
+        * messages with a custom source_name.
+        *
+        * Configuration keys:
+        *     # XXX: maybe this is too much customizability?
+        *     source-fields: SmashPig\CrmLink\Messages\SourceFields
+        *     
+        * @param array $message Will be mutated as a reference.
+        */
+       public static function addSourceFieldsToMessage( &$message ) {
+               $message['source_type'] = $type;
+               $message['source_name'] = $name;
+               $message['source_host'] = gethostname();
+               $message['source_version'] = wmf_common_get_my_revision();
+               $message['source_run_id'] = getmypid();
+               $message['source_enqueued_time'] = time();
+       }
+}
diff --git a/SmashPig.yaml b/SmashPig.yaml
index ce72eed..43e21da 100644
--- a/SmashPig.yaml
+++ b/SmashPig.yaml
@@ -162,6 +162,27 @@
             time-limit: 60
             max-messages: 0
 
+    # How to build the source_* fields when sending transactions to other
+    # components.
+    source-fields:
+        # XXX: maybe this is too much customizability?
+        class: SmashPig\CrmLink\Messages\SourceFields
+        constructor-parameters:
+
+            # You should override this in the job view, if nothing else.
+            type: unknown
+
+            name: SmashPig
+
+            # If you can't trust gethostname to return a hostname != 
"localhost",
+            # then override in your /etc with a literal like:
+            # host: payments.wmnet
+
+            # Return the version of the software that generated this
+            # message--but note that this is tricky cos we probably want the
+            # revision and identity of the outermost calling function's repo.
+            version-stamp-path: .version-stamp
+
 adyen:
     logging:
         root-context: SmashPig-Adyen

-- 
To view, visit https://gerrit.wikimedia.org/r/311884
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35a801b30a3d2565b1e4d4d1520ffc122d8c7574
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to