[ 
https://issues.apache.org/jira/browse/BEAM-3355?focusedWorklogId=88537&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-88537
 ]

ASF GitHub Bot logged work on BEAM-3355:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Apr/18 18:01
            Start Date: 06/Apr/18 18:01
    Worklog Time Spent: 10m 
      Work Description: wcn3 commented on a change in pull request #4311: 
[BEAM-3355] Diagnostic interfaces
URL: https://github.com/apache/beam/pull/4311#discussion_r179833157
 
 

 ##########
 File path: sdks/go/pkg/beam/core/runtime/harness/session.go
 ##########
 @@ -213,3 +186,59 @@ func recordFooter() error {
                },
        })
 }
+
+// CaptureHook writes the messaging content consumed and
+// produced by the worker, allowing the data to be used as
+// an input for the session runner. Since workers can exist
+// in a variety of environments, this allows the runner
+// to tailor the behavior best for its particular needs.
+type CaptureHook io.WriteCloser
+
+// CaptureHookFactory produces a CaptureHook from the supplied
+// options.
+type CaptureHookFactory func([]string) CaptureHook
+
+var captureHookRegistry = make(map[string]CaptureHookFactory)
+var enabledCaptureHook string
+
+func init() {
+       hf := func(opts []string) hooks.Hook {
+               return hooks.Hook{
+                       Init: func(_ context.Context) error {
+                               if len(opts) > 0 {
+                                       name, opts := hooks.Decode(opts[0])
+                                       capture = 
captureHookRegistry[name](opts)
+                               }
+                               return nil
+                       },
+               }
+       }
+
+       hooks.RegisterHook("session", hf)
+}
+
+// RegisterCaptureHook registers a CaptureHookFactory for the
+// supplied identifier.
+func RegisterCaptureHook(name string, c CaptureHookFactory) {
+       if _, exists := captureHookRegistry[name]; exists {
+               panic(fmt.Sprintf("RegisterSessionCaptureHook: %s registered 
twice", name))
+       }
+       captureHookRegistry[name] = c
+}
+
+// EnableCaptureHook is called to request the use of a hook in a pipeline.
+// It updates the supplied pipelines to capture this request.
+func EnableCaptureHook(name string, opts []string) {
+       if _, exists := captureHookRegistry[name]; !exists {
+               panic(fmt.Sprintf("EnableHook: %s not registered", name))
+       }
+       if enabledCaptureHook != "" {
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 88537)
    Time Spent: 9h  (was: 8h 50m)

> Make Go SDK runtime harness hooks pluggable
> -------------------------------------------
>
>                 Key: BEAM-3355
>                 URL: https://issues.apache.org/jira/browse/BEAM-3355
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Henning Rohde
>            Assignee: Bill Neubauer
>            Priority: Minor
>          Time Spent: 9h
>  Remaining Estimate: 0h
>
> We currently hardcode cpu profiling and session recording in the harness. We 
> should make it pluggable instead.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to