001/* 002Copyright 2022 The OpenFunction Authors. 003 004Licensed under the Apache License, Version 2.0 (the "License"); 005you may not use this file except in compliance with the License. 006You may obtain a copy of the License at 007 008 http://www.apache.org/licenses/LICENSE-2.0 009 010Unless required by applicable law or agreed to in writing, software 011distributed under the License is distributed on an "AS IS" BASIS, 012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013See the License for the specific language governing permissions and 014limitations under the License. 015*/ 016 017package dev.openfunction.functions; 018 019public interface Plugin { 020 /** 021 * name return the name of this plugin. 022 * 023 * @return Plugin name 024 */ 025 String name(); 026 027 /** 028 * version return the version of this plugin. 029 * 030 * @return Plugin name 031 */ 032 String version(); 033 034 /** 035 * init will create a new plugin, and execute hook in this calling. 036 * If you do not want to use a new plugin to execute hook, just return `nil`. 037 * 038 * @return Plugin 039 */ 040 Plugin init(); 041 042 043 /** 044 * execPreHook executes a hook before the function called. 045 * 046 * @param ctx Runtime context 047 * @return error 048 */ 049 Error execPreHook(Context ctx); 050 051 /** 052 * execPreHook executes a hook after the function called. 053 * 054 * @param ctx Runtime context 055 * @return error 056 */ 057 Error execPostHook(Context ctx); 058 059 /** 060 * get return the value of the fieldName` 061 * 062 * @param fieldName Name of member 063 * @return Object 064 */ 065 Object getField(String fieldName); 066}