Resource management method and device, electronic equipment, storage medium and program product
By recording and counting call information, the caller can independently manage the remaining call resources of the external interface, solving the problem of asset loss risks caused by the service provider not providing query interfaces, and realizing the autonomy and security of resource management.
Patent Information
- Application Number
- CN202411499131.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-18
AI Technical Summary
In some application scenarios, service providers do not provide the remaining call resource query interface for external interfaces, which makes it difficult for callers to manage the remaining call resources for external interfaces independently, increasing the risk of capital loss.
By recording call information, counting the called resources and managing the remaining call resources, the caller can independently calculate and manage the remaining calls of the external interface to avoid relying on the service provider's query interface.
This enables the caller to independently manage the remaining call resources of the external interface without relying on the service provider to query the interface, reducing the risk of capital loss.
Smart Images

Figure CN119476791A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource management method, device, electronic device, storage medium and program product. Background Art
[0002] In the related art, a service provider may provide an external interface to a caller, so that the caller can obtain relevant external services by calling the external interface.
[0003] Furthermore, the caller needs to purchase the call resources of the external interface from the service provider first, and then the service provider will provide the corresponding external services to it based on the purchased call resources. In the process of providing external services, the service provider will count the remaining call resources of the caller's external interface. If the caller uses up the purchased call resources, the corresponding external service will be stopped.
[0004] In some application scenarios, service providers will not provide the caller with a query interface for the remaining call resources of the external interface due to factors such as implementation complexity and security. This makes it inconvenient for the caller to manage the remaining call resources corresponding to the external interface, increasing the risk of asset loss. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a resource management method, device, electronic device, storage medium and program product, so as to enable the caller to autonomously manage the remaining calling resources of the external interface, thereby reducing the risk of asset loss.
[0006] In the first aspect, the embodiment of the present application provides a resource management method, which is applied to the caller, and the method includes: if an external service is called through an external interface, the call information is recorded; based on the call information of the external interface, the called resources of the external interface are counted; according to the total call resources of the external interface and the called resources, the remaining call resources of the external interface are managed. In this way, the caller can independently manage the remaining call resources of the external interface without relying on the query interface provided by the service provider, thereby reducing the risk of asset loss.
[0007] Optionally, the remaining call resources of the external interface include the remaining call times of the external interface, so that the counting of the called resources of the external interface based on the call information of the external interface includes: counting the number of calls of the external interface based on the call information of the external interface; and the managing of the remaining call resources of the external interface based on the total call resources of the external interface and the called resources includes: determining the remaining number of calls of the external interface based on the total number of calls of the external interface and the number of calls. In this way, the caller can independently manage the remaining number of calls of the external interface without relying on the query interface provided by the service provider, thereby reducing the risk of asset loss.
[0008] Optionally, the counting of the number of times the external interface has been called based on the call information of the external interface includes: counting the first number of times the external interface has been called based on the first call credential of the external interface; thus, the determining of the remaining number of times the external interface has been called based on the total number of times the external interface has been called includes: determining the remaining number of times the external interface has been called based on the first total number of times the external interface has been called and the first number of times the external interface has been called; the first total number of times the external interface has been called represents the total number of times the external interface has been called based on the first call credential. Thus, the first number of times the external interface has been called can be determined based on the first call credential that the caller will use when calling, and thus the remaining number of times the external interface has been called can be determined based on the first number of times the external interface has been called and the total number of times the external interface has been called.
[0009] Optionally, the counting of the first number of times the external interface has been called based on the first call credential of the external interface includes: if the external service information corresponding to the external interface is received, the number of times the first call credential is used is accumulated by 1; and the total number of times the first call credential is used is determined as the number of times the external interface has been called. In this way, the number of times the first call credential is used is accumulated once only when it is determined that the service provider has truly provided the external service information, so that the number of calls counted by itself is the same as or close to the remaining number of calls recorded in the service provider, thereby improving the accuracy of the remaining number of calls.
[0010] Optionally, the determining of the remaining number of calls of the external interface based on the total number of calls of the external interface and the number of calls already made also includes: if the remaining number of calls of the external interface is less than a preset number threshold, obtaining a second call certificate sent by the service provider and the second total number of calls of the external interface based on the second call certificate; counting the second number of calls already made to the external interface based on the second call certificate; determining the remaining number of calls of the external interface based on the second total number of calls, the second number of calls already made, the first total number of calls and the first number of calls already made. In this way, when the number of calls of a newly purchased external interface is not reset to zero, the remaining total number of calls can be reasonably managed, thereby reducing the risk of asset loss.
[0011] Optionally, after counting the number of times the external interface has been called based on the call information of the external interface, the method further includes: storing the first number of times called in a first preset storage location; for each use of the call information, storing the flow information of the call information used in the second preset storage location; in this way, determining the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of times called includes: if the number of times called is obtained in the first preset storage location, determining the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of times called; if the number of times called is not obtained from the first preset storage location within a preset time, obtaining the flow information from the second preset storage location; and determining the remaining number of calls of the external interface according to the number of the flow information and the total number of calls of the external interface. In this way, the information related to the call information can be stored in the first preset storage location and the second preset storage location respectively, so that the relevant information can be adaptively obtained from the first preset storage location or the second preset storage location according to the actual situation, so as to manage the remaining number of calls of the external interface.
[0012] Optionally, the method further includes: if the remaining number of calls of the external interface is less than a preset number threshold, determining whether the call request to be executed meets the call requirements; the call request is used to request to call the external interface; if the call request meets the call requirements, calling the external interface according to the call request; if the call request does not meet the call requirements, deferring or refusing to process the call request. In this way, when the remaining number of calls of the external interface is small, certain call requests can be restricted so that more important external services can run normally. In addition, the risk of the remaining number of calls being quickly exhausted is also reduced, which reduces the risk of asset loss to a certain extent.
[0013] Optionally, if the call request does not meet the call requirements, the call request is postponed or refused to be processed, including: if the call priority in the call request is not less than the preset priority, the call request is stored in the first request sequence, and the call request is processed according to the arrangement position in the first request sequence; if the call priority in the call request is less than the preset priority, the call request is refused to be processed; or, if the sender information in the call request is in the preset list, the call request is stored in the second request sequence, and the call request is processed according to the arrangement position in the second request sequence; if the sender information in the call request is not in the preset list, the call request is refused to be processed. In this way, by postponing or refusing to process the call request, the risk of asset loss of the caller can be reduced, and the processing pressure of the caller can also be alleviated to a certain extent.
[0014] Optionally, the method further includes: if the remaining call times of the external interface are less than a preset call times threshold, issuing a warning message, so that relevant personnel can be reminded to purchase the call times in time, reducing the risk of asset loss.
[0015] Optionally, before issuing the warning information if the remaining number of calls of the external interface is less than the preset number threshold, the method further includes: determining the total number of historical calls of the external interface within a preset historical time period; and determining the preset number threshold according to the total number of historical calls of the external interface and the preset historical time period. In this way, the preset number threshold can be determined according to the total number of historical calls of the external interface and the preset historical time period. Since the total number of historical calls reflects the actual call status of the external interface within the preset historical time period, the preset number threshold determined according to the total number of historical calls is more accurate.
[0016] In the second aspect, the embodiment of the present application provides a resource management device, which is applied to the caller, and the device includes: a recording module, which is used to record the call information if the external service is called through the external interface; a statistical module, which is used to count the called resources of the external interface based on the call information of the external interface; and a management module, which is used to manage the remaining call resources of the external interface according to the total call resources of the external interface and the called resources. In this way, the caller can independently manage the remaining call resources of the external interface without relying on the query interface provided by the service provider, thereby reducing the risk of asset loss.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect are performed.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method provided in the first aspect are performed.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect is performed.
[0020] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A flowchart of a resource management method provided in an embodiment of the present application;
[0023] Figure 2 A flowchart of a specific resource management method provided in an embodiment of the present application;
[0024] Figure 3 A structural block diagram of a resource management device provided in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of the structure of an electronic device for executing a resource management method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0027] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0028] It should be noted that the embodiments in this application or the technical features in the embodiments may be combined if there is no conflict.
[0029] In the related art, there is a problem that it is inconvenient for the caller to manage the remaining call resources of the external interface, which increases the risk of asset loss. In order to solve this problem, the present application provides a resource management method, device, electronic device, storage medium and program product; further, the caller can independently manage the remaining call resources through the total call resources of the external interface purchased by itself and the call resources it has used, thereby reducing the risk of asset loss.
[0030] The defects existing in the solutions in the above-mentioned related technologies are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above-mentioned problems and the solutions proposed in the embodiments of the present invention below for the above-mentioned problems should all be the contributions made by the inventor to the present invention during the process of the present invention.
[0031] It should be noted that the caller calls external services from the service provider through an external interface, and the service provider does not provide the caller with a query interface for the remaining calling resources of the external interface. Therefore, the present application provides a resource management method applied to the caller.
[0032] The above-mentioned caller may be, for example, a server, a server cluster or a terminal device used by the caller, etc. This application does not impose any limitation on this.
[0033] Please refer to Figure 1 , which shows a flow chart of a resource management method provided by an embodiment of the present application. Figure 1As shown, the resource management method includes the following steps 101 to 103.
[0034] Step 101, if an external service is called through an external interface, the calling information is recorded;
[0035] The above-mentioned call information can be regarded as the information required when calling the external interface. Such information may include, for example, the call credentials, the call time, whether the call is successful, etc. The above-mentioned call credentials are also the credentials used by the service provider to identify whether the external service can be called, which may include, for example, the caller account, the call password, etc.
[0036] Step 102, based on the calling information of the external interface, counting the called resources of the external interface;
[0037] The above-mentioned called resources can be regarded as resources that the caller has used through the external interface. These called resources can be determined, for example, based on the external service. For example, if the external service obtains relevant information by calling the external interface, the called resources may include, for example, the number of times the external interface has been called or the total traffic obtained through the external interface; if the external service stores information by calling the external interface, the called resources may include, for example, the storage space used through the external interface.
[0038] In some application scenarios, for example, each time an external interface is called, the resource amount of the current call is accumulated with the historical resource amount of the call to obtain the called resource. It should be noted that the historical resource amount is the resource amount of the call before the current call after the current purchase of the call resource.
[0039] Step 103: managing the remaining calling resources of the external interface according to the total calling resources of the external interface and the called resources.
[0040] The total call resources of the external interface are the call resources purchased by the caller from the service provider, such as the remaining call times, remaining call traffic or remaining storage space corresponding to the external interface.
[0041] In some application scenarios, the caller may subtract the total call resources from the called resources, and thus determine the difference between the two as the remaining call resources.
[0042] Furthermore, the caller can manage the remaining call resources. For example, when the remaining call resources are insufficient to meet the actual call demand, the caller can purchase call resources from the service provider again to increase the remaining call resources; or, when the remaining call resources are excessive, the purchase plan can be postponed to reduce the remaining call resources. In this way, the remaining call resources can be matched with the actual needs.
[0043] In this implementation, the caller does not need to rely on the query interface provided by the service provider, and can independently manage the remaining call resources of the external interface, thereby reducing the risk of asset loss.
[0044] See also Figure 2 , which shows a flow chart of a resource management method provided by an embodiment of the present application. The resource management method is used to manage the remaining number of calls to the external interface, such as Figure 2 As shown, the resource management method includes the following steps 201 to 203.
[0045] Step 201, if an external service is called through an external interface, the calling information is recorded;
[0046] Step 202, based on the calling information of the external interface, counting the number of times the external interface has been called;
[0047] In some application scenarios, the caller may determine the number of recorded call information as the number of calls; in other application scenarios, the caller may filter the recorded call information and then determine the number of filtered call information as the number of calls. For example, the call information that failed to be called due to abnormal call request is filtered out.
[0048] Step 203: Determine the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of calls already made.
[0049] The total number of calls to the above external interface is also the number of calls purchased by the caller from the service provider.
[0050] In some application scenarios, the caller may subtract the total number of calls from the number of calls already made, and thus determine the difference between the two as the remaining number of calls.
[0051] Furthermore, the caller can manage the remaining call times. For example, when the remaining call times are insufficient to meet the actual call demand, the caller can purchase the call times from the service provider again to increase the remaining call times; or, when the remaining call times are excessive, the purchase plan can be postponed to reduce the remaining call times. In this way, the remaining call times can be matched with the actual needs.
[0052] In this implementation, the caller does not need to rely on the query interface provided by the service provider, and can independently manage the remaining number of calls to the external interface, thereby reducing the risk of asset loss.
[0053] It should be noted that if the service provider provides a query interface, when the query interface is not sufficient to meet the needs of the caller, the present implementation method can also be used to achieve autonomous management of the remaining number of calls, thereby reducing the risk of asset loss.
[0054] In some application scenarios, when a caller requests to call an external interface, the service provider can identify the caller's call information to determine whether the caller has the call authority.
[0055] Therefore, in some optional implementations, the counting of the number of times the external interface has been called based on the call information of the external interface in the above step 202 includes sub-step 2021: counting the first number of times the external interface has been called based on the first call credential of the external interface;
[0056] The first calling credential is also the credential used by the service provider to identify whether the caller can call the external interface.
[0057] In some application scenarios, the caller may send the first call credential each time it calls the external interface, so that the service provider can provide the corresponding external service after the authentication is passed.
[0058] Therefore, each time the caller calls the external interface, the first calling credential is used once. Therefore, the number of times the first calling credential is used can be determined as the first number of called times.
[0059] In this way, the above-mentioned step 203 described in which the remaining number of calls of the external interface is determined based on the total number of calls of the external interface and the number of calls already made includes: determining the remaining number of calls of the external interface based on the first total number of calls of the external interface and the first number of calls already made; the first total number of calls represents the total number of times the external interface is called based on the first call credential.
[0060] In this implementation, the first call count can be determined based on the first call credential that the caller will use when making the call, so that the remaining call count of the external interface can be determined based on the first call count and the total call count.
[0061] In some optional implementations, the counting of the first number of times the external interface has been called based on the first calling credential of the external interface in the above sub-step 2021 includes: first, if the external service information corresponding to the external interface is received, the number of times the first calling credential is used is accumulated by 1;
[0062] It should be noted that in some application scenarios, service providers often count the number of calls only after they have successfully provided external services to the caller. If the service provider determines that the remaining number of calls of the external interface purchased by the caller has been reset to zero, or there is abnormal information in the call request, which actually causes the service provider to fail to successfully provide the external service to the caller, the service provider will not reduce the remaining number of calls.
[0063] Therefore, when the caller receives the external service information, it can be determined that the service provider has recorded a call count, and the remaining call count is reduced by one. Thus, the caller can add one to the usage count of the first call voucher.
[0064] Then, the total number of times the first calling credential is used is determined as the number of times the external interface has been called.
[0065] In this implementation, the number of times the first call credential is used is accumulated once only when it is determined that the service provider has truly provided the external service information, so that the number of calls counted by itself is the same or close to the remaining number of calls recorded in the service provider, thereby improving the accuracy of the remaining number of calls.
[0066] In some application scenarios, after the caller has purchased the call times, there may be a situation where the historical purchased times have not been used up. Therefore, in some optional implementations, the determination of the remaining call times of the external interface according to the total call times of the external interface and the number of calls in step 203 above includes:
[0067] First, if the remaining number of calls of the external interface is less than a preset number threshold, a second call credential sent by the service provider and a second total number of calls of the external interface based on the second call credential are obtained;
[0068] Here, when the remaining number of calls of the external interface is less than the preset number threshold, it can be considered that the number of calls needs to be repurchased. After the relevant personnel successfully purchase, the service provider can send a new call voucher, which is also the above-mentioned second call voucher. In addition, the relevant personnel can also know the total number of calls purchased, which is also the above-mentioned second total number of calls.
[0069] It should be noted that the second calling credential mentioned above may be the same as or different from the first calling credential, and this application does not impose any restrictions on this.
[0070] Then, based on the second calling credential, counting the second number of times the external interface has been called;
[0071] It should be noted that the process of counting the second number of calls and the technical effects obtained may be similar to the process of counting the first number of calls and the technical effects mentioned above, and will not be repeated here.
[0072] Secondly, the remaining number of calls of the external interface is determined according to the second total number of calls, the second number of calls completed, the first total number of calls, and the first number of calls completed.
[0073] In some application scenarios, the difference between the second total call count and the second called count and the difference between the first total call count and the first called count may be added together to obtain the remaining call count available for the external interface.
[0074] In these application scenarios, for example, it can also be set that when calling an external interface, the call is made based on the first call credential first, so that the remaining number of calls corresponding to the first call credential can be cleared first, so as to reduce management matters and improve management convenience.
[0075] In this implementation, when the number of calls to the newly purchased external interface is increased and the remaining number of historical calls is not cleared, the total number of remaining calls can be properly managed, thereby reducing the risk of asset loss.
[0076] In some optional implementations, after counting the number of times the external interface has been called based on the call information of the external interface in step 202, the method further includes:
[0077] Firstly, the first called times is stored in a first preset storage location;
[0078] The first preset storage location may be, for example, Redis (an open source key-value storage system, RemoteDictionary Server, referred to as Redis), Memcached (memory cache), etc.
[0079] Then, for each use of the calling information, the running information of the calling information is stored in the second preset storage location;
[0080] The second preset storage location mentioned above may be, for example, a database.
[0081] It should be noted that the first preset storage location may be, for example, a location with a faster reading speed, and the second preset storage location may be, for example, a location with a higher data storage performance. Thus, corresponding information content may be adaptively stored in both locations.
[0082] Thus, the step 203 described above, determining the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of calls already made, includes:
[0083] First, if the number of times the external interface has been called is obtained in the first preset storage location, the remaining number of times the external interface has been called is determined according to the total number of times the external interface has been called and the number of times the external interface has been called;
[0084] Here, since the first preset storage location stores only the number of times that have been called, the rate of reading the number of times that have been called is faster, which improves the management efficiency of the remaining usage times to a certain extent.
[0085] In some application scenarios, there may be situations such as network interruption, damage to the first preset storage location, etc., which may result in failure to normally obtain the number of calls from the first preset storage location.
[0086] Therefore, if the number of calls is not obtained from the first preset storage location within the preset time, the transaction information is obtained from the second preset storage location; and the remaining number of calls of the external interface is determined based on the amount of the transaction information and the total number of calls of the external interface.
[0087] The above-mentioned flow information is also the relevant information of the usage call information, which may include, for example, the operator identity, usage time and other information.
[0088] In some application scenarios, the caller can create a call record table to record transaction information. The call record table can be, for example:
[0089] CREATE TABLE`call_record_log`(
[0090] `id`bigint(20)unsigned NOT NULL AUTO_INCREMENT COMMENT'self-increment id',
[0091] `out_method_name`varchar(256)NOT NULL DEFAULT"COMMENT'external service method name',
[0092] `out_param_extra`varchar(256)NOT NULL DEFAULT"COMMENT'Call parameter json',
[0093] `result`tinyint(4)NOT NULL DEFAULT'1'COMMENT'Whether it is successful, 1-success, 0-failure',
[0094] `is_del`tinyint(4)NOT NULL DEFAULT'0'COMMENT'Is it deleted',
[0095] `create_user`varchar(16)NOT NULL DEFAULT"COMMENT'creator',
[0097] `create_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT'creation time',
[0098] `modify_user`varchar(16)NOT NULL DEFAULT"COMMENT'modifier',
[0099] `modify_time`datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATECURRENT_TIMESTAMP COMMENT'modification time',
[0100] PRIMARY KEY(`id`),
[0101] KEY`idx_caller_name`(`caller_name`)
[0102] )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Call record table';
[0103] In these application scenarios, the caller can obtain transaction information and count the number of transaction information to subtract the total number of calls of the external interface from the number of transaction information to obtain the remaining number of calls of the external interface.
[0104] In this implementation, information related to the call information can be stored in the first preset storage location and the second preset storage location respectively, so that relevant information can be adaptively obtained from the first preset storage location or the second preset storage location according to actual conditions, so as to manage the remaining number of calls to the external interface.
[0105] In some application scenarios, when the number of remaining calls to the external interface is small, the call request may be limited for the normal operation of some important services. Then, in some optional implementations, the method further includes:
[0106] Step 1: If the remaining number of calls of the external interface is less than a preset number threshold, determine whether the call request to be executed meets the call requirement; the call request is used to request to call the external interface;
[0107] In some application scenarios, the above-mentioned preset number threshold can be set according to experience, for example, set to 30%, 40% of the total number of calls, etc.
[0108] The above-mentioned call requirements may include, for example, whether the call priority is within a preset priority, whether the call request is sent by a core user, or whether the call request is sent from a preset important geographical area, etc.
[0109] It should be noted that when each user sends a call request, he or she can set the corresponding priority information, IP information, user information, etc. in the call request, so that the caller can subsequently determine whether the corresponding call request meets the call requirements based on this.
[0110] Step 2: If the calling request meets the calling requirement, calling the external interface according to the calling request;
[0111] Step 3: If the call request does not meet the call requirements, the call request is postponed or rejected.
[0112] In this implementation, when the remaining call times of the external interface are small, some call requests can be restricted so that more important external services can run normally. In addition, the risk of the remaining call times being exhausted quickly is reduced, which reduces the risk of asset loss to a certain extent.
[0113] In some optional implementations, if the call request does not meet the call requirement in step 3 above, deferring or refusing to process the call request includes:
[0114] First, if the calling priority in the calling request is not less than the preset priority, the calling request is stored in the first request sequence, and the calling request is processed according to the arrangement position in the first request sequence;
[0115] The above-mentioned preset priority can be set, for example, according to the importance of the external service, or according to the time urgency of the external service, and this application does not impose any limitation on this.
[0116] In some application scenarios, if there are multiple call requests with a call priority not less than a preset priority, for example, the multiple call requests can be stored sequentially in the first request sequence according to the receiving time, so that the external interface can be called sequentially to achieve the purpose of delayed processing.
[0117] Secondly, if the call priority in the call request is lower than the preset priority, the call request is rejected;
[0118] It should be noted that if the call priority of the call request is lower than the preset priority, it can be determined that the external service corresponding to the call request is relatively less important or less urgent, so the external interface can be called to obtain the relevant external service after repurchasing the call times. Then, the call request can be rejected at present.
[0119] In addition, if the sender information in the call request is in the preset list, the call request is stored in the second request sequence, and the call request is processed according to the arrangement position in the second request sequence; if the sender information in the call request is not in the preset list, the call request is refused.
[0120] The above-mentioned preset list may include, for example, list information of important users, or list information of important geographical areas, etc., and this application does not impose any limitation on this.
[0121] It should be noted that the process of determining to postpone or refuse to process a call request through a preset list is similar to the previous one and will not be repeated here.
[0122] In this implementation, by postponing or refusing to process the call request, the risk of asset loss of the caller can be reduced, and the processing pressure of the caller can be alleviated to a certain extent.
[0123] In some optional implementations, the method further includes: if the remaining number of calls to the external interface is less than a preset number threshold, issuing a warning message.
[0124] The above-mentioned warning information may include, for example, issuing an alarm sound, or sending a warning text message to relevant personnel.
[0125] In these application scenarios, the caller can, for example, monitor periodically or in real time whether the remaining number of calls is less than a preset number threshold, so as to issue a warning message in a timely manner.
[0126] In the related technology, when the remaining number of calls is less than a certain amount, the service provider can send an email to the caller informing him that the number of calls is about to be reset. However, since the relevant personnel need to spend a certain amount of time to make the purchase, if the purchase is not successful when the remaining number of calls is reset, the caller will not be able to call the external interface, thereby causing asset loss.
[0127] In this implementation, a warning message can be issued when the remaining number of calls of the external interface is less than a preset number threshold, thereby reminding relevant personnel to purchase the number of calls in time, thereby reducing the risk of asset loss.
[0128] In some optional implementations, the total number of historical calls of the external interface within a preset historical time period may be determined first; then, the preset number threshold may be determined based on the total number of historical calls of the external interface and the preset historical time period.
[0129] The preset historical time period may include, for example, a time period three months or five months before the current date, or may include the same time period in previous years.
[0130] In some application scenarios, the caller can determine the total number of historical calls to the external interface within a preset historical time period, and then determine the average number, minimum number or median number of times the external interface is called within the preset historical time period based on the total number of historical calls, so as to determine it as the preset number threshold.
[0131] In this implementation, the preset number threshold can be determined based on the total number of historical calls of the external interface and the preset historical time period. Since the total number of historical calls reflects the actual calling situation of the external interface within the preset historical time period, the preset number threshold determined based on the total number of historical calls is more accurate.
[0132] It should be noted that if the resource management method is used to manage remaining call resources such as remaining traffic of an external interface, remaining storage space, etc., its management process may be similar to the process of managing its remaining call times, and this application will not go into details.
[0133] Those skilled in the art will appreciate that, in the above method of a specific embodiment, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0134] Please refer to Figure 3 , which shows a structural block diagram of a resource management device provided in an embodiment of the present application, and the resource management device may be a module, program segment or code on an electronic device. It should be understood that the device corresponds to the above method embodiment and can execute each step involved in the method embodiment.
[0135] Optionally, the above-mentioned device includes a recording module 301, a statistical module 302 and a management module 303, wherein the recording module 301 is used to record the calling information if the external service is called through the external interface; the statistical module 302 is used to count the called resources of the external interface based on the calling information of the external interface; the management module 303 is used to manage the remaining calling resources of the external interface according to the total calling resources of the external interface and the called resources.
[0136] Optionally, the remaining calling resources of the external interface include the remaining calling times of the external interface, so that the above-mentioned statistical module 302 is further used to: based on the calling information of the external interface, count the number of times the external interface has been called; so that the management module 303 is further used to: determine the remaining calling times of the external interface based on the total number of calls of the external interface and the number of calls.
[0137] Optionally, the statistical module 302 is further used to: based on the first calling credential of the external interface, count the first number of times the external interface has been called; in this way, the determination module 303 is further used to: determine the remaining number of calls to the external interface based on the total number of first calls to the external interface and the first number of calls; the first total number of calls represents the total number of times the external interface is called based on the first calling credential.
[0138] Optionally, the statistical module 302 is further used to: if external service information corresponding to the external interface is received, add 1 to the number of times the first calling credential is used; and determine the total number of times the first calling credential is used as the number of times the external interface has been called.
[0139] Optionally, the management module 303 is further used to: if the remaining number of calls to the external interface is less than a preset number threshold, obtain a second call credential sent by the service provider and the total number of second calls to the external interface based on the second call credential; based on the second call credential, count the second number of calls to the external interface; determine the remaining number of calls to the external interface based on the second total number of calls, the second number of calls, the first total number of calls and the first number of calls.
[0140] Optionally, the device also includes a storage module, which is used to: after counting the number of times the external interface has been called based on the calling information of the external interface, store the first number of times the external interface has been called in a first preset storage location; for each use of the calling information, store the flow information of the call information used this time in a second preset storage location; in this way, the management module 303 is further used to: if the number of times the external interface has been called is obtained in the first preset storage location, determine the remaining number of times the external interface has been called according to the total number of times the external interface has been called and the number of times the external interface has been called; if the number of times the external interface has been called is not obtained from the first preset storage location within a preset time length, obtain the flow information from the second preset storage location; and determine the remaining number of times the external interface has been called according to the amount of the flow information and the total number of times the external interface has been called.
[0141] Optionally, the device also includes a current limiting module, which is used to: if the remaining number of calls of the external interface is less than a preset number threshold, determine whether the call request to be executed meets the call requirements; the call request is used to request to call the external interface; if the call request meets the call requirements, call the external interface according to the call request; if the call request does not meet the call requirements, postpone or refuse to process the call request.
[0142] Optionally, the above-mentioned current limiting module is further used to: if the call priority existing in the call request is not less than the preset priority, then the call request is stored in the first request sequence, and the call request is processed according to the arrangement position in the first request sequence; if the call priority existing in the call request is less than the preset priority, then the call request is refused to be processed; or, if the sender information existing in the call request is in the preset list, then the call request is stored in the second request sequence, and the call request is processed according to the arrangement position in the second request sequence; if the sender information existing in the call request is not in the preset list, then the call request is refused to be processed.
[0143] Optionally, the device further comprises an early warning module, and the early warning module is used to issue an early warning message if the remaining call times of the external interface are less than a preset call times threshold.
[0144] Optionally, the device also includes a determination module, which is used to: determine the total number of historical calls of the external interface within a preset historical time period before issuing a warning message if the remaining number of calls of the external interface is less than a preset number threshold; determine the preset number threshold based on the total number of historical calls of the external interface and the preset historical time period.
[0145] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system or device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0146] Please refer to Figure 4 , Figure 4 A structural diagram of an electronic device for executing a resource management method provided in an embodiment of the present application, the electronic device may include: at least one processor 401, such as a CPU, at least one communication interface 402, at least one memory 403 and at least one communication bus 404. Among them, the communication bus 404 is used to realize direct connection and communication between these components. Among them, the communication interface 402 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 403 can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 403 can optionally be at least one storage device located away from the aforementioned processor. Computer-readable instructions are stored in the memory 403. When the computer-readable instructions are executed by the processor 401, the electronic device can execute the above-mentioned Figure 1 The method process is shown.
[0147] Understandably, Figure 4 The structure shown is for illustration only, and the electronic device may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0148] The present application embodiment provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the following can be performed: Figure 1 Any implementation method in the method embodiment shown.
[0149] An embodiment of the present application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments. For example, the method may include: if an external service is called through an external interface, recording the call information; based on the call information of the external interface, counting the called resources of the external interface; and managing the remaining call resources of the external interface according to the total call resources of the external interface and the called resources.
[0150] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, 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 communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0151] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0152] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0153] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0154] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A resource management method, characterized in that: Applied to the caller, the method includes: If an external service is called through an external interface, the call information is recorded; Based on the calling information of the external interface, counting the called resources of the external interface; The remaining calling resources of the external interface are managed according to the total calling resources of the external interface and the called resources.
2. The method according to claim 1, characterized in that The remaining call resources of the external interface include the remaining call times of the external interface, and The counting of called resources of the external interface based on the calling information of the external interface includes: Based on the call information of the external interface, counting the number of times the external interface has been called; and The managing the remaining calling resources of the external interface according to the total calling resources of the external interface and the called resources comprises: The remaining number of calls of the external interface is determined according to the total number of calls of the external interface and the number of calls already made.
3. The method according to claim 2, characterized in that The counting of the number of times the external interface has been called based on the call information of the external interface includes: Based on the first calling credential of the external interface, counting a first calling number of the external interface; and The determining, according to the total number of calls of the external interface and the number of calls already made, the remaining number of calls of the external interface comprises: The remaining number of calls of the external interface is determined according to a first total number of calls of the external interface and the first number of calls; the first total number of calls represents the total number of calls of the external interface based on the first call credential.
4. The method according to claim 3, characterized in that The counting of the first number of times the external interface has been called based on the first calling credential of the external interface includes: If the external service information corresponding to the external interface is received, the number of times the first calling credential is used is increased by 1; The total number of times the first calling credential is used is determined as the number of times the external interface has been called.
5. The method according to any one of claims 3 or 4, characterized in that: The determining the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of calls already made also includes: If the remaining number of calls of the external interface is less than the preset number threshold, obtaining a second call credential sent by the service provider and a second total number of calls of the external interface based on the second call credential; Based on the second calling credential, counting a second number of times the external interface has been called; The remaining number of calls of the external interface is determined according to the second total number of calls, the second number of calls completed, the first total number of calls, and the first number of calls completed.
6. The method according to claim 3, characterized in that After counting the number of times the external interface has been called based on the call information of the external interface, the method further includes: storing the first number of called times in a first preset storage location; For each use of the calling information, storing the running information of the calling information at the second preset storage location; and The determining, according to the total number of calls of the external interface and the number of calls already made, the remaining number of calls of the external interface comprises: If the number of calls is obtained in the first preset storage location, determining the remaining number of calls of the external interface according to the total number of calls of the external interface and the number of calls; If the number of calls is not obtained from the first preset storage location within the preset time, the transaction information is obtained from the second preset storage location; and the remaining number of calls of the external interface is determined based on the amount of the transaction information and the total number of calls of the external interface.
7. The method according to claim 2, characterized in that The method further comprises: If the remaining number of calls of the external interface is less than the preset number threshold, determining whether the call request to be executed meets the call requirement; the call request is used to request to call the external interface; If the calling request meets the calling requirement, calling the external interface according to the calling request; If the call request does not meet the call requirement, the processing of the call request is postponed or rejected.
8. The method according to claim 7, characterized in that If the call request does not meet the call requirement, deferring or refusing to process the call request includes: If the call priority in the call request is not less than the preset priority, the call request is stored in the first request sequence, and the call request is processed according to the arrangement position in the first request sequence; if the call priority in the call request is less than the preset priority, the call request is rejected; or, If the sender information in the call request is in the preset list, the call request is stored in the second request sequence and processed according to the arrangement position in the second request sequence; if the sender information in the call request is not in the preset list, the call request is refused.
9. The method according to claim 2, characterized in that: The method further comprises: If the remaining number of calls to the external interface is less than a preset number threshold, a warning message is issued.
10. The method according to claim 9, characterized in that Before issuing a warning message if the remaining number of calls of the external interface is less than a preset number threshold, the method further includes: Determine the total number of historical calls of the external interface within a preset historical time period; The preset number threshold is determined according to the total number of historical calls of the external interface and the preset historical time period.
11. A resource management device, characterized in that: Applied to the caller, the device comprises: A recording module is used to record the call information if an external service is called through an external interface; A statistics module, used for counting the called resources of the external interface based on the calling information of the external interface; The management module is used to manage the remaining calling resources of the external interface according to the total calling resources of the external interface and the called resources.
12. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 10 is executed.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is executed.
14. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method according to any one of claims 1 to 10 is performed.