# Overview

The function of service orchestration has been introduced in the previous tutorial. Service orchestration is mainly to quickly generate an aggregate interface based on existing business microservices using online configuration. When processing input parameters or results, data conversion or calculation is often required. At this time, commonly used built-in functions can be used to handle it. If the function cannot handle it, it can be implemented by writing a script. FizzGate version requirements: v2.3 or above. Functions start with fn., such as fn.date.timestamp(), date is the category, and the gateway has built-in functions of the following categories:

  • Public class fn.common
  • Date class fn.date
  • String class fn.string
  • Codec class fn.codec
  • Math fn.math
  • Data list class fn.list

Example:

For a list of all supported functions, please refer to the official documentation: [Function Usage Document](https://www.fizzgate.com/fizz/guide/aggregate/function.html#%E5%85%AC%E5%85%B1%E7 %B1%BB-fn-common)

# Reference value

Reference values are supported in functions, such as:

fn.string.concat({step1.result.channelCode},{step1.result.nonce})

{step1.result.channelCode} represents a reference value, which refers to the value of the channelCode field in the step1 result.

fn.string.concat({step1.result.channelCode},{g.account.name})

{g.account.name} represents a reference value, which refers to the public resource "account.name". Starting with g represents a reference to a public resource. Public resources can define key (Key) value (Value) pairs of data and are referenced in the service orchestration interface. Key (Key) to obtain the value (Value), thereby avoiding hardcoding the value in the interface. Menu location: Alarm Management > Public Resources. Click the menu to enter the public resource list page, as shown in the figure.

manager_global_resource_query

Public Resource Usage Document (opens new window)

# Nested calls

Supports multiple nested calls, such as:

fn.codec.md5(
     fn.date.add(
         fn.date.add(
             "2021-07-09 22:44:55",
             "yyyy-MM-dd HH:mm:ss",
             1, 
             fn.math.addExact(999,1)
         ),
         "yyyy-MM-dd HH:mm:ss",
         fn.math.addExact(0,1),
         1000
     )
)
fn.string.toUpperCase(
     fn.codec.sha256(
         fn.string.concat(
             {step1.result.channelCode},
             {step1.result.nonce},
             {step1.result.timestamp},
             {step1.result.appSecret}
         )
     )
)

# Data preparation

# FizzGate integrated platform installation

Please refer to: https://www.fizzgate.com/fizz/guide/installation (opens new window)

# Function sample demonstration

In the menu: Service Orchestration->Interface List, add a service orchestration interface/test/func for demonstration. The interface is hung under the service1 service (if there is no service, you can add one). Define three input parameters, namely num1 and num2. Two numbers are used to demonstrate numerical comparison, and age is used to demonstrate judgment based on age. Because this example does not involve calling the "configuration step" from an external interface, it can be left blank. As shown in the picture:

Add the following output fields to the configuration output:

  • currentTime: Get the current time
  • threeHoursLater: current time plus 3 hours
  • birthdayFromIDCard: Extract the birthday from the ID card and format it for display
  • cardTypeByAge: If the age is greater than or equal to 60, return the senior card, otherwise return the ordinary card
  • signature: Use SHA256 encryption to generate a signature
  • maxNum: Returns the maximum of two numbers

Click the test button in the upper right corner to enter the test page, fill in the Query parameters, and click Send to get the results:

Function-based nested calls can implement relatively complex operations and meet the needs of most daily operations. For more usage, please refer to the official documentation: [Service Orchestration-Function](https://www.fizzgate.com/fizz/guide/ aggregate/function.html)

# Introduction to FizzGate Integration Platform

FizzGate is a microservice aggregation gateway developed based on Java. It can achieve hot service orchestration and aggregation, automatic authorization selection, online service script coding, online testing, high-performance routing, API audit management, callback management, etc., and has powerful customization The plug-in system can be expanded by itself and provides a friendly graphical configuration interface, which can quickly help enterprises manage API services, reduce middle-layer glue codes, reduce coding investment, and improve the stability and security of API services.

Official website: https://www.fizzgate.com (opens new window)

GitHub: https://github.com/fizzgate/fizz-gateway-node (opens new window)

Code cloud: https://gitee.com/fizzgate/fizz-gateway (opens new window)

Getting Started Tutorial: https://www.fizzgate.com/fizz/guide/GettingStarted/ (opens new window)

Advanced tutorial: https://www.fizzgate.com/fizz/guide/advanced/ (opens new window)


Author: Blackhawk