1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef CONTRIB_JSNONNET_BASE_TRANSACTION_H_ 16 #define CONTRIB_JSNONNET_BASE_TRANSACTION_H_ 17 18 #include <memory> 19 #include <string> 20 21 #include "jsonnet_base_sandbox.h" // NOLINT(build/include) 22 23 class JsonnetTransaction : public sapi::Transaction { 24 public: JsonnetTransaction(std::string in_file,std::string out_file)25 JsonnetTransaction(std::string in_file, std::string out_file) 26 : sapi::Transaction( 27 std::make_unique<JsonnetBaseSandbox>(in_file, out_file)), 28 in_file_(in_file), 29 out_file_(out_file) { 30 sapi::Transaction::set_retry_count(0); // Try once, no retries 31 sapi::Transaction::SetTimeLimit(0); // Infinite time limit 32 } 33 34 private: 35 std::string in_file_; 36 std::string out_file_; 37 38 absl::Status Main() override; 39 }; 40 41 #endif // CONTRIB_JSNONNET_BASE_TRANSACTION_H_ 42