[ 
https://issues.apache.org/jira/browse/MINIFICPP-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16235592#comment-16235592
 ] 

ASF GitHub Bot commented on MINIFICPP-110:
------------------------------------------

Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/163#discussion_r148353398
  
    --- Diff: extensions/script/ExecuteScript.h ---
    @@ -0,0 +1,94 @@
    +/**
    + * @file ExecuteScript.h
    + * ExecuteScript class declaration
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +#ifndef NIFI_MINIFI_CPP_EXECUTESCRIPT_H
    +#define NIFI_MINIFI_CPP_EXECUTESCRIPT_H
    +
    +#include <concurrentqueue.h>
    +#include <core/Resource.h>
    +#include <core/Processor.h>
    +
    +#include "ScriptEngine.h"
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace processors {
    +
    +class ExecuteScript : public core::Processor {
    + public:
    +  explicit ExecuteScript(const std::string &name, uuid_t uuid = nullptr)
    +      : Processor(name, uuid),
    +        logger_(logging::LoggerFactory<ExecuteScript>::getLogger()),
    +        script_engine_q_() {
    +  }
    +
    +  static core::Property ScriptEngine;
    +  static core::Property ScriptFile;
    +  static core::Property ScriptBody;
    +  static core::Property ModuleDirectory;
    +
    +  static core::Relationship Success;
    +  static core::Relationship Failure;
    +
    +  void initialize() override;
    +  void onSchedule(core::ProcessContext *context, 
core::ProcessSessionFactory *sessionFactory) override;
    +  void onTrigger(core::ProcessContext *context, core::ProcessSession 
*session) override;
    +
    + private:
    +  std::shared_ptr<logging::Logger> logger_;
    +
    +  std::string script_engine_;
    +  std::string script_file_;
    +  std::string script_body_;
    +  std::string module_directory_;
    +
    +  moodycamel::ConcurrentQueue<std::shared_ptr<script::ScriptEngine>> 
script_engine_q_;
    +
    +  template<typename T>
    +  std::shared_ptr<T> createEngine() const {
    +    auto engine = std::make_shared<T>();
    +
    +    engine->bind("log", logger_);
    +    engine->bind("REL_SUCCESS", Success);
    +    engine->bind("REL_FAILURE", Failure);
    +
    +    return std::move(engine);
    +  }
    +
    +  template<typename T>
    +  void triggerEngineProcessor(const std::shared_ptr<script::ScriptEngine> 
&engine,
    +                              core::ProcessContext *context,
    +                              core::ProcessSession *session) const {
    +    T *typed_engine = static_cast<T *>(engine.get());
    --- End diff --
    
    Can you not use the static_pointer_cast since this is already a shared_ptr?


> Implement ExecuteScript
> -----------------------
>
>                 Key: MINIFICPP-110
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-110
>             Project: NiFi MiNiFi C++
>          Issue Type: New Feature
>            Reporter: Andrew Christianson
>            Assignee: Andrew Christianson
>            Priority: Major
>
> Initially support python and lua.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to