Function state updating method and device, electronic equipment and medium
By introducing a method of dynamically managing the working status of the target function in the service cluster, the real-time configuration update of the function switch is realized, solving the problem of inefficient updates in traditional solutions, and improving the response speed and stability of the business system.
Patent Information
- Application Number
- CN202510591239.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-08
AI Technical Summary
Traditional functional switch status updates are inefficient and cannot respond quickly to emergency problems or trial and error, resulting in slow response to business systems.
By introducing dynamic management of the working status of the target function in the service cluster, operations and maintenance or technicians can modify the working status information of the target function without touching any business code and configure it to the service cluster to complete configuration updates, realizing instant configuration updates of the function switches.
The function can be switched on or off quickly without recompiling, packaging or restarting the service, which improves update efficiency, avoids slow response problems caused by code review, testing, and grayscale release, and ensures the stability and flexibility of the business system.
Smart Images

Figure CN120455277A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network operation and maintenance, and in particular to a function status updating method, device, electronic device and medium. Background Art
[0002] At present, all industries have developed relevant business systems for their own businesses, which serve as user-facing applications or are directly used to perform related business management. There are many functions such as "new user registration" in the business system. Traditional function switches often hard-code the logic of whether to enable a function in the program, and the judgment conditions are usually written in the code (for example, using if statements). If you want to change the on / off status of a function, you must modify the code, recompile, package, and then go through a series of steps such as code review, testing, and grayscale release before it can be put online. This method is slow to respond when facing urgent problems or when rapid trial and error is required, making the update of the function switch status inefficient. Summary of the Invention
[0003] The main purpose of the embodiments of the present application is to propose a function status update method, device, electronic device and medium, aiming to improve the efficiency of function switch status update of a business system as a service cluster.
[0004] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a function status update method, which is applied to a service cluster. The method includes:
[0005] In response to the modification operation, modify the first working status information of the target function of the service cluster to obtain second working status information, where the second working status information and the first working status information are used to indicate whether the target function is turned on or off;
[0006] The target function is configured and updated according to the second working status information.
[0007] In some implementations, before updating the configuration of the target function according to the second working state information, the method further includes:
[0008] Acquire target object information, where the target object information is used to indicate a target object targeted by the modification operation, where the target object is at least one of a plurality of service objects of the service cluster, and the service object sends a function usage request to the service cluster, where the function usage request is used to request use of the target function;
[0009] The updating of the configuration of the target function according to the second working state information includes:
[0010] The target function is configured and updated according to the second working state information, and it is determined that the configuration update is effective for the target object.
[0011] In some embodiments, before modifying the first working status information of the target function of the service cluster in response to the modification operation to obtain the second working status information, the method further includes:
[0012] Acquire first working state information of the target function;
[0013] The first working status information is configured and associated with the target function, and the configuration association is used to indicate whether the target function is turned on or off using the first working status information.
[0014] In some embodiments, the service cluster is communicatively connected to an information storage component, and the first working status information and the second working status information are stored in the information storage component. After the configuration of the target function is updated according to the second working status information, the method further includes:
[0015] receiving a function usage request from a service object, wherein the function usage request is used to request the use of the target function;
[0016] In response to the function use request, sending a query request for second working state information to the information storage component;
[0017] Obtaining a query result for the query request sent by the information storage component, wherein the query result is used to indicate whether the second working status information indicates that the target function is turned on or off;
[0018] When the second working state information indicates that the target function is enabled, executing execution logic corresponding to the target function;
[0019] In a case where the second working status information indicates that the target function is turned off, a function turn-off prompt is sent to the service object, where the function turn-off prompt is used to prompt that the target function is turned off.
[0020] In some embodiments, the method further comprises:
[0021] Recording the number of query requests and the number of modification operations within a preset time period;
[0022] When the number of query requests is greater than a first threshold and the number of modification operations is greater than a second threshold, determining that the target function is a function to be optimized;
[0023] An optimization operation for the function to be optimized is obtained, and the execution logic of the target function is modified according to the optimization operation.
[0024] In some embodiments, the service cluster includes a plurality of cluster nodes;
[0025] Each of the cluster nodes is in communication with an information storage component, the first working status information and the second working status information are stored in the information storage component, and the configuration and updating of the target function according to the second working status information includes:
[0026] By each of the cluster nodes responding to the update notification sent by the information storage component using the publishing mechanism, the first working status information in the cache of each of the cluster nodes is updated to the second working status information;
[0027] Each of the cluster nodes updates the configuration of the target function by using the second working status information in the cache.
[0028] In some embodiments, the first working state information is associated with a first execution logic of the target function, and the second working state information is associated with a second execution logic of the target function, and the first execution logic is different from the second execution logic;
[0029] After updating the configuration of the target function according to the second working state information, the method further includes:
[0030] When both the second working status information and the first working status information indicate that the target function is in the on state, in response to the obtained version rollback operation, the second working status information is rolled back to the first working status information, and the version rollback operation is used to instruct the service cluster to execute the target function according to the first execution logic.
[0031] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a function status update device, which is applied to a service cluster. The device includes:
[0032] a modification module, configured to modify, in response to a modification operation, first working status information of a target function of the service cluster to obtain second working status information, wherein the second working status information and the first working status information are used to indicate whether the target function is turned on or off;
[0033] An updating module is used to update the configuration of the target function according to the second working status information.
[0034] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the functional status update method described in the first aspect when executing the computer program.
[0035] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the functional status update method described in the first aspect above.
[0036] The function status update method, device, electronic device and medium proposed in this application realize the instant configuration update of the function switch by introducing dynamic management of the working status of the target function in the service cluster configured with the business system: when the operation and maintenance or technical personnel initiate the modification operation, the service cluster will modify the first working status information of the target function (i.e. whether it is currently turned on) to the second working status information (used to indicate that the target function should be turned on or off) without touching any business code, and then configure the status to the service cluster to complete the configuration update. Relying on the first working status information and the second working status information indicating whether the target function is turned on or off, the entire process can quickly complete the on or off switching of the function without recompiling, packaging or restarting the service, thereby improving the update efficiency; at the same time, it avoids the slow response problem caused by the lengthy code review, testing, gray release and other links in the traditional solution, so that it can quickly respond to emergency needs or rapid trial and error scenarios, effectively ensuring the stability and flexibility of the business system. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 Schematic diagram of the function status update method provided in the embodiment of the present application;
[0038] Figure 2 This is another flowchart of the function status updating method provided in an embodiment of the present application;
[0039] Figure 3 This is another flowchart of the function status updating method provided in the embodiment of the present application;
[0040] Figure 4 This is another flowchart of the function status updating method provided in the embodiment of the present application;
[0041] Figure 5 This is a schematic diagram of the structure of the function status updating device provided in an embodiment of the present application;
[0042] Figure 6 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0044] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0046] First, let’s analyze some of the terms used in this application:
[0047] Service Cluster: A service cluster is a group of service instances with the same functionality and configuration (usually running on multiple servers or cloud containers, or on a single server that can accommodate multiple instances), which work together to provide the same set of business capabilities. Its main functions include:
[0048] 1. When an instance fails or goes offline, other instances in the cluster can continue to provide external services, ensuring that the configuration and business systems are not shut down.
[0049] 2. User requests can be distributed to different instances through a load balancer to achieve horizontal distribution of request pressure and avoid single point overload.
[0050] 3. Dynamically increase or decrease the number of instances based on business load to ensure sufficient capacity during peak periods and conserve resources during off-peak periods.
[0051] 4. Instances in a cluster share the same configuration. Operations and maintenance personnel can issue configuration updates (such as function switch status) to the entire cluster at one time, simplifying the management process.
[0052] A business system refers to a complete set of information technology software developed or purchased by an enterprise or organization to support its daily business processes. It includes front-end user interfaces, back-end business logic processing, and integration with various data stores and external systems. It typically covers functions such as order management, customer relationship management, financial accounting, and human resources. It provides end users with the necessary operational access and automatically executes business rules and data flows in the background, helping enterprises achieve business automation, standardization, and visualization.
[0053] Based on this, the embodiments of the present application provide a function status update method, electronic device and medium, which aim to improve the efficiency of function switch status update of the business system as a service cluster.
[0054] The functional status update method, device, electronic device and medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the functional status update method in the embodiments of the present application is described.
[0055] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.
[0056] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0057] The functional status update method provided in the embodiment of the present application relates to the field of network operation and maintenance. The functional status update method provided in the embodiment of the present application is applied to the terminal, and can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the functional status update method, etc., but is not limited to the above forms.
[0058] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0059] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the user's identity or characteristics, such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of such data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0060] Figure 1 This is a flow chart of the function status update method provided in the embodiment of the present application. Figure 1 As shown, a first aspect of an embodiment of the present application provides a function status update method, which is applied to a service cluster configured with a business system, including the following steps S100 to S200.
[0061] Step S100: In response to the modification operation, the first working status information of the target function of the service cluster is modified to obtain second working status information, and the second working status information and the first working status information are used to indicate whether the target function is turned on or off.
[0062] First, upon receiving a modification request from operations or business personnel, the service cluster updates the first operational status information for the target function in the service cluster to the second operational status information. This means that no business logic code is touched or services are redeployed. Instead, the status record stored in a unified configuration store (e.g., Redis) is modified to indicate whether the target function should be enabled or disabled.
[0063] For example, for the "new user registration" function of the insurance business system, after the operation and maintenance personnel clicks "Close Registration" in the management background, the front end can call the / api / feature / update interface through HTTP POST and send the request body {"featureName":"NEW_SIGN_UP","enabled":false} to the service cluster; the service cluster first reads the first working status information under the key feature_switch:NEW_SIGN_UP from Redis (for example, {featureName:"NEW_SIGN_UP",enabled:true}), and then modifies it to the second working status information {featureName:"NEW_SIGN_UP",enabled:false} and writes it back to Redis to complete the status update.
[0064] Step S200: updating the configuration of the target function according to the second working status information.
[0065] In this step, the service cluster will update the configuration of the target function according to the second working state information just generated, so that all instances (ie, cluster nodes) in the service cluster can automatically synchronize the new switch state, thereby taking effect quickly.
[0066] Specifically, the service cluster can publish a function update event after updating Redis (for example, push a message to the feature_updated channel through RedisPub / Sub). After each cluster node subscribes to the channel, it can immediately pull the latest second working status information and refresh the local cache.
[0067] A service cluster can be built based on the Spring Boot microservice architecture. In this way, all methods annotated with @FeatureGuard("NEW_SIGN_UP") in the service cluster can be intercepted by Spring AOP aspects. The aspect checks the enabled flag in the local cache or Redis to decide whether to release the registration logic or throw a FeatureDisabledException.
[0068] For example, after completing the Redis write operation and publishing the feature_updated event, the subscription component of each service instance in the cloud container cluster can capture this event and read {enabled:false} through redisTemplate.opsForHash().get("feature_switch:NEW_SIGN_UP"). Subsequently, when the user (i.e., the service object of the business system) uses the client to initiate a POST / register registration request, the AOP aspect will intercept the method call. Since the local cache (or Redis) shows that the registration function is disabled, the aspect directly blocks the execution of the business logic and returns a "feature disabled" prompt, allowing the configuration update to take effect immediately without restarting the service.
[0069] Through the above steps S100-S200, dynamic management of the working status of the target function is introduced in the service cluster configured with the business system, and instant configuration update of the function switch is realized: when the operation and maintenance or technical personnel initiate a modification operation, the service cluster will modify the first working status information of the target function (i.e. whether it is currently turned on) to the second working status information (used to indicate that the target function should be turned on or off) without touching any business code, and then configure the status to the service cluster to complete the configuration update. Relying on the first working status information and the second working status information indicating whether the target function is turned on or off, the entire process can quickly complete the on or off switching of the function without recompiling, packaging or restarting the service, thereby improving the update efficiency; at the same time, it avoids the slow response problem caused by lengthy code review, testing, gray release and other links in traditional solutions, so that it can quickly respond to emergency needs or rapid trial and error scenarios, effectively ensuring the stability and flexibility of the business system.
[0070] Figure 2 This is another flow chart of the function status update method provided in the embodiment of the present application. Figure 2 As shown, in some embodiments, before updating the configuration of the target function according to the second working state information (step S200), the method further includes:
[0071] Step S110: Acquire target object information, where the target object information indicates the target object targeted by the modification operation. The target object is at least one of multiple service objects in the service cluster. The service object sends a function usage request to the service cluster, where the function usage request is used to request the use of the target function.
[0072] The target function is configured and updated according to the second working state information (step S200), including:
[0073] Step S210: updating the configuration of the target function according to the second working state information, and determining whether the configuration update is effective for the target object.
[0074] In this implementation, the service cluster's service targets are client users. Whenever they initiate a function request through the client (for example, accessing the "New User Registration" interface), the service cluster determines whether to allow the function to execute based on pre-configured status. During a grayscale release, i.e., when determining the target objects for a function configuration update, operations and maintenance personnel can specify the target objects in a single modification operation—that is, a group of service objects that will experience the new function first or block the old function first.
[0075] Specifically, after receiving the modification operation, the service cluster first obtains the target object information (such as users in a certain region, VIP users, or a sample of 10% of users). It then modifies the first working status information originally stored in Redis, representing all users, to the second working status information. It then writes the second working status information only to the configuration key associated with the target object (for example, feature_switch:NEW_SIGN_UP:regionE ast or feature_switch:NEW_SIGN_UP:groupA). The service cluster then publishes the update event to the corresponding feature_updated:regionEast channel via RedisPub / Sub.
[0076] The Spring AOP aspect with @FeatureGuard("NEW_SIGN_UP") added will read the second working status information corresponding to the target object to which the service object belongs in the local cache (or Redis) when intercepting a function usage request (such as a request to register a new user) from a service object belonging to the target object. Only when it is set to be enabled will the function execution logic be released. Otherwise, FeatureDisabledException will be thrown and a prompt indicating that the function is disabled will be returned. Other service objects that are not within the grayscale range (that is, within the effective object range) will continue to determine whether to execute the target function according to the first working status information, thereby achieving precise grayscale release that is only effective for some service objects.
[0077] For example, suppose an insurance company's application wants to first allow users in East China to experience the new verification code process for the "New User Registration" function. The operation and maintenance personnel modify the service cluster:
[0078] POST / api / feature / update
[0079] {
[0080] "featureName":"NEW_SIGN_UP",
[0081] "enabled":true,
[0082] "targetObjects":["regionEast"]
[0083] }
[0084] The service cluster detects that the target user is a user in East China. It then changes the feature_switch:NEW_SIGN_UP:regionEast setting in Redis from {enabled:false} to {enabled:true} and sends a notification to the feature_updated:regionEast channel. From then on, when users in East China call POST / register on their mobile devices or the web, the corresponding service instance first refreshes the local cache to enabled=true via subscription. After the AOP aspect passes detection, the new registration logic is executed. Requests from users in other regions remain unaffected because the local cache still contains the old state.
[0085] In some embodiments, before modifying the first working status information of the target function of the service cluster in response to the modification operation to obtain the second working status information, the method further includes:
[0086] Acquire first working state information of the target function;
[0087] The first working state information is configured to be associated with the target function. The configuration association is used to indicate whether the target function is turned on or off using the first working state information.
[0088] In this embodiment, after the service cluster obtains the first working status information of the target function configured by the operation and maintenance personnel, it configures and associates the first working status information with the target function, so that the subsequent components of the service cluster can use this first working status information to determine whether the target function is currently turned on or off.
[0089] For example, in the "new user registration" scenario, the configuration association process can be: the service cluster obtains the field of the operation and maintenance personnel's custom annotation @FeatureGuard and adds the "NEW_SIGN_UP" identifier representing the target function of new user registration, and obtains @FeatureGuard("NEW_SIGN_UP"), @FeatureGuard("NEW_SIGN_UP") defines that the opening or closing of the target function of new user registration is indicated by the first working status information.
[0090] After the configuration association is completed, the service cluster first reads the first working status information saved under the key feature_switch:NEW_SIGN_UP from Redis (for example, {featureName:"NEW_SIGN_UP",enabled:true}) and loads it into the service cluster. The Spring AOP aspects of all service instances in the service cluster will use this information to decide whether to allow the registration interface (@FeatureGuard("NEW_SIGN_UP")) to be intercepted. When a user initiates a POST / register request through the client, the aspect reads the enabled flag associated with the configuration in the local cache, thereby correctly executing the logic or directly throwing a function shutdown exception.
[0091] Figure 3 This is another flow chart of the function status update method provided in the embodiment of the present application, such as Figure 3 As shown, in some embodiments, the service cluster is communicatively connected to the information storage component, and the first working status information and the second working status information are stored in the information storage component. After the target function is configured and updated according to the second working status information (step S200), the method further includes:
[0092] Step S300: receiving a function usage request from a service object, where the function usage request is used to request the use of a target function;
[0093] Step S400: In response to the function use request, sending a query request for the second working state information to the information storage component;
[0094] Step S500: obtaining a query result for the query request sent by the information storage component, where the query result is used to indicate whether the second working state information indicates that the target function is turned on or off;
[0095] Step S600: When the second working state information indicates that the target function is enabled, executing the execution logic corresponding to the target function;
[0096] Step S700: When the second working status information indicates that the target function is turned off, a function turn-off prompt is sent to the service object, where the function turn-off prompt is used to prompt that the target function is turned off.
[0097] Figure 4 This is another flow chart of the function status update method provided in the embodiment of the present application. Please refer to Figure 3-Figure 4In some embodiments, the service cluster maintains a communication connection with an information storage component so that the first working status information and the second working status information of the target function are uniformly stored in the information storage component. The information storage component can be a Redis database. After the service cluster completes the configuration update based on the second working status information, the service cluster continues to listen for function usage requests from each service object. Once a client initiates a function usage request, the business service cluster immediately sends a query request to the Redis database to obtain the latest second working status information.
[0098] After receiving the query, the Redis database returns a corresponding result, indicating whether the target function is currently enabled or disabled. The service cluster then makes a decision based on this result: if the second working status information indicates that the target function is enabled, the service cluster executes the corresponding business logic; if it indicates that the target function is disabled, a function shutdown notification is returned to the service object, informing the user that the function is temporarily unavailable.
[0099] For example, in the "new user registration" scenario, when the operation and maintenance personnel update the second working status information of the registration function to Redis through the management API (POST / api / feature / update), the registration request POST / register from the client will be intercepted by the Spring AOP aspect; the aspect sends a query request to Redis through redisTemplate.opsForHash().get("feature_switch:NEW_SIGN_UP") and obtains a query result such as {enabled:false}. Since the query result shows that the registration function is disabled, the aspect immediately throws FeatureDisabledException and returns a prompt "New user registration function is disabled" to the client without executing subsequent registration logic; if the query result is {enabled:true}, the aspect is released and the functional logic is executed normally, realizing real-time interception and response to function usage requests.
[0100] In some embodiments, the method further comprises:
[0101] Record the number of query requests and modification operations within a preset time period;
[0102] When the number of query requests is greater than a first threshold and the number of modification operations is greater than a second threshold, determining the target function as a function to be optimized;
[0103] Get the optimization operation for the function to be optimized, and modify the execution logic of the target function according to the optimization operation.
[0104] In this embodiment, the service cluster will continuously monitor the frequency of calls to the target function and the frequency of modifications to its status, and record the number of query requests and modification operations received within the "preset time period" in the background; when these two indicators exceed the pre-set "first threshold" and "second threshold" respectively, it can be seen that the target function switches more than usual when the request volume is large, indicating that the operation and maintenance personnel are constantly switching the on / off status of the target function, and performing troubleshooting when turning off the target function, and the fault or functional defect has not been eliminated after multiple troubleshooting.
[0105] For example, for the "New User Registration" function, the service cluster counted over 50,000 queries to the / register interface in the past 10 minutes (the first threshold), and the operations staff frequently toggled the function switch more than 20 times (the second threshold). The service cluster identified the "New User Registration" function as being in a high call and high toggle state and marked it as a "function to be optimized."
[0106] After the service cluster marks the target function as "function to be optimized", it can obtain the optimization operations entered by the operation and maintenance personnel, and finally adjust the execution logic of the target function based on the optimization operations to improve the stability and performance of the service cluster.
[0107] In some embodiments, the service cluster includes a plurality of cluster nodes;
[0108] Each cluster node is in communication with the information storage component, the first working state information and the second working state information are stored in the information storage component, and the target function is configured and updated according to the second working state information, including:
[0109] By each cluster node responding to the update notification sent by the information storage component using the publishing mechanism, the first working status information in the cache of each cluster node is updated to the second working status information;
[0110] Each cluster node uses the second working state information in the cache to update the configuration of the target function.
[0111] In this embodiment, the function status update method provided in the present application embodiment operates within a service cluster consisting of multiple cluster nodes. Each cluster node maintains a communication connection with the same information storage component to uniformly manage the on / off status of the target function. The first operating status information and second operating status information of all functions are stored in the information storage component, which can be a Redis database.
[0112] When the target function's status is modified in the Redis database, the database uses its publishing mechanism to send an update notification to the relevant channel. Each cluster node subscribes to this channel and, upon receiving the notification, automatically replaces the first working state information stored in the local cache with the second working state information in Redis, completing the local cache refresh.
[0113] Next, the cluster nodes update the configuration of the target function based on the second working status information in the updated local cache - releasing the business logic when the function is turned on, and intercepting and returning a shutdown prompt when the function is turned off, thereby ensuring that all nodes in the entire service cluster can quickly adopt the new functional status without restarting or manual intervention.
[0114] For example, in the scenario of the "new user registration" function, the operation and maintenance personnel initiate the following through the management API:
[0115] POST / api / feature / update
[0116] {"featureName":"NEW_SIGN_UP","enabled":false}
[0117] This request is written to the corresponding hash key in Redis (for example, feature_switch:NEW_SIGN_UP), and Redis then publishes a notification to the feature_updated channel. After receiving this notification, the cluster nodes running on each container instance perform similar operations as follows:
[0118] localCache.put("NEW_SIGN_UP",
[0119] redisTemplate.opsForHash().get("feature_switch","NEW_SIGN_UP"));
[0120] This updates the first working status information in the local cache to the second working status information (false in this case). When a user subsequently calls the registration interface annotated with @FeatureGuard("NEW_SIGN_UP"), the Spring AOP aspect will first read enabled=false from the local cache and throw a FeatureDisabledException, returning a "New user registration feature is disabled" prompt to the client without restarting the service or accessing Redis again, ensuring real-time feature status switching and consistency within the cluster.
[0121] In some embodiments, the first working status information is associated with a first execution logic of the target function, and the second working status information is associated with a second execution logic of the target function, and the first execution logic is different from the second execution logic;
[0122] After updating the configuration of the target function according to the second working state information, the method further includes:
[0123] When both the second working status information and the first working status information indicate that the target function is in the on state, in response to the obtained version rollback operation, the second working status information is rolled back to the first working status information. The version rollback operation is used to instruct the service cluster to execute the target function according to the first execution logic.
[0124] In this embodiment, the target function corresponds to different execution logics under different versions, and the first working status information is associated with the first execution logic of the target function, and the second working status information is associated with the second execution logic of the target function, and there are differences in the functional behaviors of the two. That is to say, when running the initial version (version 1), the service cluster executes the "first execution logic" according to the first working status information; when upgrading to the new version (version 2) and updating the status to the second working status information, the service cluster changes to execute the "second execution logic". If after the new version is launched, the operation and maintenance personnel initiate a "version rollback" operation - this operation instructs the service cluster to restore to the first execution logic - then as long as the first working status information and the second working status information currently show that the function is in the "on" state, the service cluster will roll back the second working status information to the first working status information, so that all cluster nodes will re-execute the first execution logic.
[0125] For example, for the "New User Registration" function, version 1 (the first execution logic) only verifies basic information and directly registers; version 2 (the second execution logic) adds an SMS verification code verification process. The operation and maintenance personnel update the status of feature_switch:NEW_SIGN_UP in Redis from {enabled:true,version:1} to {enabled:true,version:2} and publish a feature_updated notification. After that, the Spring AOP aspect will read {version:2} when intercepting POST / register and execute the second execution logic with the SMS verification code. If the new process is found to be unstable in grayscale or real environments, the operation and maintenance personnel will call:
[0126] POST / api / feature / rollback
[0127] {"featureName":"NEW_SIGN_UP","toVersion":1}
[0128] After confirming that both the first and second working status information are enabled:true, the service cluster rolls back the status in Redis to {enabled:true,version:1} and uses the publish / subscribe mechanism to refresh the local cache on all cluster nodes. At this point, the AOP aspect detects version:1 again and resumes executing the first execution logic without the verification code, smoothly switching between the old and new versions without restarting the service or manually modifying the business code.
[0129] The function status update method provided in the embodiment of the present application realizes the instant configuration update of the function switch by introducing dynamic management of the working status of the target function in the service cluster configured with the business system: when the operation and maintenance or technical personnel initiate a modification operation, the service cluster will modify the first working status information of the target function (i.e. whether it is currently turned on) to the second working status information (used to indicate that the target function should be turned on or off) without touching any business code, and then configure the status to the service cluster to complete the configuration update. Relying on the first working status information and the second working status information indicating whether the target function is turned on or off, the entire process can quickly complete the on or off switching of the function without recompiling, packaging or restarting the service, which greatly improves the update efficiency; at the same time, it avoids the slow response problem caused by lengthy code review, testing, gray release and other links in the traditional solution, so that it can quickly respond to emergency needs or rapid trial and error scenarios, effectively ensuring the stability and flexibility of the business system.
[0130] Furthermore, this application also supports grayscale release of target functions within the scope of specific service objects. The service cluster can configure and associate the second working status information with the specified subset user group, so that the new status is only issued within this subset without affecting other users, ensuring that the risk of full release is minimized; at the same time, each node deployed in the cluster establishes communication with Redis and subscribes to status update notifications. Once the status changes, the first working status information in the local cache is immediately replaced with the second working status information, achieving millisecond-level status synchronization; in order to cope with high-concurrency scenarios and frequent status queries, the service cluster can automatically trigger local cache optimization and temporarily store hot query results for a period of time. The preset duration can significantly reduce the back-end storage access overhead and improve the response performance. In addition, this solution also has a built-in monitoring and adaptive optimization mechanism, which can count the function call and switching frequency. When both exceed the preset threshold, the function is automatically identified as an item to be optimized, and the optimization operation is dynamically loaded (such as adjusting the local cache invalidation strategy or the current limiting and degradation plan). Finally, when the old and new logic coexist and the function remains turned on, the service cluster supports one-click version rollback - just restore the second working status information to the first working status information to allow the service cluster to smoothly switch back to the original execution logic without redeployment or downtime, thereby achieving efficiency, security and controllability of the entire life cycle of function updates.
[0131] See also Figure 5 The embodiment of the present application further provides a function status updating device 50, which is applied to a service cluster and can implement the above function status updating method. The device 50 includes:
[0132] a modification module 51 configured to modify, in response to a modification operation, first working status information of a target function of the service cluster to obtain second working status information, the second working status information and the first working status information being used to indicate whether the target function is enabled or disabled;
[0133] The updating module 52 is configured to update the configuration of the target function according to the second working state information.
[0134] In some embodiments, the apparatus 50 further comprises:
[0135] An acquisition module is configured to acquire target object information, where the target object information indicates the target object targeted by the modification operation. The target object is at least one of multiple service objects in the service cluster. The service object sends a function usage request to the service cluster, where the function usage request is used to request the use of the target function.
[0136] The update module 52 includes:
[0137] The configuration updating unit is configured to update the configuration of the target function according to the second working state information, and determine whether the configuration update is effective for the target object.
[0138] In some embodiments, the apparatus 50 further comprises:
[0139] A pre-acquisition module, configured to acquire first working state information of a target function;
[0140] The association module is used to configure the association between the first working state information and the target function, and the configuration association is used to indicate whether the target function is turned on or off using the first working state information.
[0141] In some embodiments, the apparatus 50 further comprises:
[0142] A receiving module is used to receive a function use request from a service object, where the function use request is used to request the use of a target function;
[0143] a sending module, configured to send a query request for the second working state information to the information storage component in response to the function use request;
[0144] A query module, configured to obtain a query result for the query request sent by the information storage component, wherein the query result is used to indicate whether the second working state information indicates that the target function is turned on or off;
[0145] An execution module, configured to execute execution logic corresponding to the target function when the second working state information indicates that the target function is enabled;
[0146] The prompt module is used to send a function closure prompt to the service object when the second working status information indicates that the target function is closed, and the function closure prompt is used to prompt the target function to be closed.
[0147] In some embodiments, the apparatus 50 further comprises:
[0148] A recording module is used to record the number of query requests and modification operations within a preset time period;
[0149] a determination module, configured to determine that the target function is a function to be optimized when the number of query requests is greater than a first threshold and the number of modification operations is greater than a second threshold;
[0150] The optimization module is used to obtain optimization operations for the function to be optimized and modify the execution logic of the target function according to the optimization operations.
[0151] In some embodiments, the service cluster includes a plurality of cluster nodes;
[0152] Each cluster node is in communication with the information storage component, and the first working status information and the second working status information are stored in the information storage component. The updating module 52 includes:
[0153] a notification unit, configured to update the first working status information in the cache of each cluster node to the second working status information by having each cluster node respond to the update notification sent by the information storage component using the publishing mechanism;
[0154] The updating unit is configured to update the configuration of the target function by using the second working state information in the cache through each cluster node.
[0155] In some embodiments, the first working status information is associated with a first execution logic of the target function, and the second working status information is associated with a second execution logic of the target function, and the first execution logic is different from the second execution logic;
[0156] The device 50 further comprises:
[0157] When both the second working status information and the first working status information indicate that the target function is in the on state, in response to the obtained version rollback operation, the second working status information is rolled back to the first working status information. The version rollback operation is used to instruct the service cluster to execute the target function according to the first execution logic.
[0158] The specific implementation of the function status updating device 50 is basically the same as the specific embodiment of the above-mentioned function status updating method, and will not be repeated here.
[0159] The present application also provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned function status update method when executing the computer program. The electronic device can be any smart terminal including a tablet computer, an in-vehicle computer, or the like.
[0160] See also Figure 6 , Figure 6 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0161] The processor 601 may be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0162] The memory 602 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 602 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 602 and is called by the processor 601 to execute the function status update method of the embodiments of this application.
[0163] Input / output interface 603, used to implement information input and output;
[0164] Communication interface 604, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0165] Bus 605 , which transmits information between various components of the device (e.g., processor 601 , memory 602 , input / output interface 603 , and communication interface 604 );
[0166] The processor 601 , the memory 602 , the input / output interface 603 and the communication interface 604 are connected to each other in communication within the device via a bus 605 .
[0167] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned function status update method.
[0168] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0169] The function status update method, device, electronic device and storage medium provided in the embodiments of the present application realize the instant configuration update of the function switch by introducing dynamic management of the working status of the target function in the service cluster configured with the business system: when the operation and maintenance or technical personnel initiate the modification operation, the service cluster will modify the first working status information of the target function (i.e. whether it is currently turned on) to the second working status information (used to indicate that the target function should be turned on or off) without touching any business code, and then configure the status to the service cluster to complete the configuration update. Relying on the first working status information and the second working status information indicating whether the target function is turned on or off, the entire process can quickly complete the on or off switching of the function without recompiling, packaging or restarting the service, thereby improving the update efficiency; at the same time, it avoids the slow response problem caused by the lengthy code review, testing, gray release and other links in the traditional solution, so that it can quickly respond to emergency needs or rapid trial and error scenarios, effectively ensuring the stability and flexibility of the business system.
[0170] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0171] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0172] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0173] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0174] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0175] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0176] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0177] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0178] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0179] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0180] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A function status update method, characterized in that: Applied to a service cluster, the method includes: In response to the modification operation, modify the first working status information of the target function of the service cluster to obtain second working status information, where the second working status information and the first working status information are used to indicate whether the target function is turned on or off; The target function is configured and updated according to the second working status information.
2. The method according to claim 1, characterized in that Before updating the configuration of the target function according to the second working state information, the method further includes: Acquire target object information, where the target object information is used to indicate a target object targeted by the modification operation, where the target object is at least one of a plurality of service objects of the service cluster, and the service object sends a function usage request to the service cluster, where the function usage request is used to request use of the target function; The updating of the configuration of the target function according to the second working state information includes: The target function is configured and updated according to the second working state information, and it is determined that the configuration update is effective for the target object.
3. The method according to claim 1, characterized in that Before modifying the first working status information of the target function of the service cluster in response to the modification operation to obtain the second working status information, the method further includes: Acquire first working state information of the target function; The first working status information is configured and associated with the target function, and the configuration association is used to indicate whether the target function is turned on or off using the first working status information.
4. The method according to claim 1, wherein The service cluster is communicatively connected to an information storage component, the first working status information and the second working status information are stored in the information storage component, and after the configuration of the target function is updated according to the second working status information, the method further includes: receiving a function usage request from a service object, wherein the function usage request is used to request the use of the target function; In response to the function use request, sending a query request for second working state information to the information storage component; Obtaining a query result for the query request sent by the information storage component, wherein the query result is used to indicate whether the second working status information indicates that the target function is turned on or off; When the second working state information indicates that the target function is enabled, executing execution logic corresponding to the target function; In a case where the second working status information indicates that the target function is turned off, a function turn-off prompt is sent to the service object, where the function turn-off prompt is used to prompt that the target function is turned off.
5. The method according to claim 4, characterized in that The method further comprises: Recording the number of query requests and the number of modification operations within a preset time period; When the number of query requests is greater than a first threshold and the number of modification operations is greater than a second threshold, determining that the target function is a function to be optimized; An optimization operation for the function to be optimized is obtained, and the execution logic of the target function is modified according to the optimization operation.
6. The method according to claim 1, characterized in that The service cluster includes multiple cluster nodes; Each of the cluster nodes is in communication with an information storage component, the first working status information and the second working status information are stored in the information storage component, and the configuration and updating of the target function according to the second working status information includes: By each of the cluster nodes responding to the update notification sent by the information storage component using the publishing mechanism, the first working status information in the cache of each of the cluster nodes is updated to the second working status information; Each of the cluster nodes updates the configuration of the target function by using the second working status information in the cache.
7. The method according to claim 1, characterized in that The first working state information is associated with a first execution logic of the target function, and the second working state information is associated with a second execution logic of the target function, wherein the first execution logic is different from the second execution logic; After updating the configuration of the target function according to the second working state information, the method further includes: When both the second working status information and the first working status information indicate that the target function is in the on state, in response to the obtained version rollback operation, the second working status information is rolled back to the first working status information, and the version rollback operation is used to instruct the service cluster to execute the target function according to the first execution logic.
8. A function status updating device, characterized in that: Applied to a service cluster, the device includes: a modification module, configured to modify, in response to a modification operation, first working status information of a target function of the service cluster to obtain second working status information, wherein the second working status information and the first working status information are used to indicate whether the target function is turned on or off; An updating module is used to update the configuration of the target function according to the second working status information.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the functional status updating method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the function status updating method according to any one of claims 1 to 7 is implemented.