zwoop commented on code in PR #10191: URL: https://github.com/apache/trafficserver/pull/10191#discussion_r1316384698
########## example/cripts/example1.cc: ########## @@ -0,0 +1,242 @@ +/* + 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. +*/ + +// The primary include file, this has to always be included +#include <cripts/Preamble.hpp> + +#include <cripts/Bundles/Common.hpp> + +// Globals for this Cript +static Matcher::Range::IP CRIPT_ALLOW({"192.168.201.0/24", "10.0.0.0/8"}); + +// This is called only when the plugin is initialized +do_init() +{ + TSDebug("Cript", "Hello, example1 plugin is being initialized"); +} + +do_create_instance() +{ + instance.metrics[0] = Metrics::Sum::create("cript.example1.c0"); Review Comment: Yeh, so the concept of instances was added after Cripts was initially done. It was really done to make it possible to write regular remap plugins taking @pparam options. My vision was that for the normal case, when Cripts are integrated into your deployment system, you wouldn't use instance data but rather generate a Cript which is both the code and the configuration. I.e. no @pparam options in remap.config. The instance data is a std::array of a type that can hold int, float, string, ptr's etc. This is a "power user" feature (plugin writers), and not as user friendly as most of Cripts. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
