//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// Licensed 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Jan Steemann //////////////////////////////////////////////////////////////////////////////// #include "v8-ttl.h" #include "Basics/Result.h" #include "VocBase/Methods/Ttl.h" #include "V8/v8-globals.h" #include "V8/v8-utils.h" #include "V8/v8-vpack.h" #include #include using namespace arangodb; /// @brief returns the TTL properties static void JS_TtlProperties(v8::FunctionCallbackInfo const& args) { TRI_V8_TRY_CATCH_BEGIN(isolate); v8::HandleScope scope(isolate); if (args.Length() > 1) { TRI_V8_THROW_EXCEPTION_USAGE("properties()"); } VPackBuilder builder; Result result; if (args.Length() == 0) { // get properties result = methods::Ttl::getProperties(builder); } else { // set properties VPackBuilder properties; int res = TRI_V8ToVPack(isolate, properties, args[0], false); if (res != TRI_ERROR_NO_ERROR) { TRI_V8_THROW_EXCEPTION(res); } result = methods::Ttl::setProperties(properties.slice(), builder); } if (result.fail()) { THROW_ARANGO_EXCEPTION(result); } v8::Handle obj = TRI_VPackToV8(isolate, builder.slice()); TRI_V8_RETURN(obj); TRI_V8_TRY_CATCH_END } /// @brief returns the TTL statistics static void JS_TtlStatistics(v8::FunctionCallbackInfo const& args) { TRI_V8_TRY_CATCH_BEGIN(isolate); v8::HandleScope scope(isolate); VPackBuilder builder; Result result = methods::Ttl::getStatistics(builder); if (result.fail()) { THROW_ARANGO_EXCEPTION(result); } v8::Handle obj = TRI_VPackToV8(isolate, builder.slice()); TRI_V8_RETURN(obj); TRI_V8_TRY_CATCH_END } /// @brief initializes the ttl functions void TRI_InitV8Ttl(v8::Isolate* isolate) { v8::HandleScope scope(isolate); TRI_AddGlobalFunctionVocbase(isolate, TRI_V8_ASCII_STRING(isolate, "SYS_TTL_STATISTICS"), JS_TtlStatistics); TRI_AddGlobalFunctionVocbase(isolate, TRI_V8_ASCII_STRING(isolate, "SYS_TTL_PROPERTIES"), JS_TtlProperties); }