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

Declarative flush callback #71

Open
tpluscode opened this issue Jan 23, 2023 · 0 comments
Open

Declarative flush callback #71

tpluscode opened this issue Jan 23, 2023 · 0 comments

Comments

@tpluscode
Copy link
Contributor

It is sometimes useful to take advantage of the flush callback to step streams.

For example, I used the SHACL step in a way that pipeline does not fail immediately on error but stores reports in memory and only fails the pipeline at the end. Another use case that could be implemented with flush would be to call hooks when pipeline finishes

My current SHACL looks somewhat like this

<#validate>
  a :Step ;
  code:implementedBy
    [
      code:link <node:barnard59-validate-shacl/validate.js#shacl> ;
      a code:EcmaScriptModule ;
    ] ;
  code:arguments
    [ code:name "shape" ; code:value <#Shapes> ] ,
    [
      code:name "onViolation" ;
      code:value [ a code:EcmaScriptModule ; code:link <file:../lib/shacl.js#collectShaclReports> ] ;
    ];
.

<#checkShaclReports>
   a :Step ;
  code:implementedBy
    [
      code:link <file:../lib/shacl.js#failOnAnyViolations> ;
      a code:EcmaScriptModule ;
    ] ;
.

The failOnAnyViolations stream is essentially a PassThrough with the second callback.

I would like to propose an optional property for steps, which would combine both:

<#validate>
  a :Step ;
  code:implementedBy
    [
      code:link <node:barnard59-validate-shacl/validate.js#shacl> ;
      a code:EcmaScriptModule ;
    ] ;
  code:arguments
    [ code:name "shape" ; code:value <#Shapes> ] ,
    [
      code:name "onViolation" ;
      code:value [ a code:EcmaScriptModule ; code:link <file:../lib/shacl.js#collectShaclReports> ] ;
    ];
+ :after
+   [
+     code:implementedBy
+       [ 
+         code:link <file:../lib/shacl.js#failOnAnyViolations> ;
+         a code:EcmaScriptModule ;
+       ] ;
+   ] ;
.

-<#checkShaclReports>
-  a :Step ;
- code:implementedBy
-   [
-     code:link <file:../lib/shacl.js#failOnAnyViolations> ;
-     a code:EcmaScriptModule ;
-   ] ;
-.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant