Session reconstruction method, apparatus, device, storage medium and product
Patent Information
- Application Number
- CN202611191812.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-10-30
AI Technical Summary
由于各服务实例相互独立、内存数据不互通,新服务实例无法获取原交互过程中的历史信息,只能从零开始处理或丢弃已有结果,导致会话内容中断、处理断层,严重影响业务连续性
本申请提供的会话重建方案,在与第一服务实例进行会话期间,通过在本地保存会话上下文,使得会话的历史处理状态得以在终端侧留存。在与第一服务实例的会话断开的情况下,终端基于本地保存的会话上下文构造重连请求,实现了将历史处理状态随身携带的效果,避免了因实例切换导致的状态丢失。终端向服务器发送该重连请求后,由服务器将重连请求分配至第二服务实例,第二服务实例能够基于该会话上下文恢复该会话,从而在无需中心化存储、不改造服务端架构的前提下,实现了会话上下文在无状态服务集群中的随连接迁移与快速重建,有效避免了因服务实例切换导致的会话处理断层,保障了会话的连续性与处理质量,同时降低了系统复杂度和运维成本。
Smart Images

Figure CN123020635A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of streaming data processing technology, and in particular to a session reconstruction method, apparatus, device, storage medium, and product. Background Technology
[0002] In a distributed stateless service cluster architecture, service instances are stateless, relying on load balancing mechanisms to achieve dynamic request distribution and fault tolerance. For real-time business scenarios requiring continuous interaction, it is necessary to maintain the continuity of historical information during continuous interaction to ensure session continuity and processing quality.
[0003] However, when a client disconnects and reconnects, the load balancing mechanism will most likely distribute the reconnection request to a new service instance. Since each service instance is independent and their memory data is not shared, the new service instance cannot obtain historical information from the original interaction process and can only start processing from scratch or discard existing results, resulting in interrupted session content, processing gaps, and severely impacting business continuity.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this application is to provide a session reconstruction method, apparatus, device, storage medium, and product that can prevent the loss of session processing state due to service instance switching and improve session continuity.
[0006] To achieve the above objectives, this application proposes a session reconstruction method, executed by a terminal, the method comprising: During a session with the first service instance in the stateless service cluster, the session context is saved. If the session with the first service instance is terminated, a reconnection request is constructed based on the session context; The reconnection request is sent to the server so that the server allocates the reconnection request to a second service instance in the stateless service cluster, and the second service instance restores the session based on the session context.
[0007] Optionally, saving the session context during a session with the first service instance in the stateless service cluster includes: During a session with the first service instance, receive the streaming processing result returned by the first service instance in response to the streaming input data sent by the terminal; From the streaming processing results, identify the finalized processing result segments; The finalized processing result fragment is saved as the session context.
[0008] Optionally, identifying the finalized processing result fragment from the streaming processing results includes: Detect whether each processing result segment in the streaming processing result reaches the preset content boundary; The processing result fragment that reaches the content boundary is identified as the finalized processing result fragment.
[0009] Optionally, identifying the finalized processing result fragment from the streaming processing results includes: Detect the receiving time interval between each processing result segment in the streaming processing result; If the receiving time interval between adjacent processing result segments exceeds a preset time threshold, the previous processing result segment in the adjacent processing result segments will be determined as the finalized processing result segment.
[0010] Optionally, after saving the finalized processing result fragment as the session context, the method further includes: Obtain the revised segment for the processed result segment of the finalized draft; Locate the original fragment corresponding to the corrected fragment from the storage area of the session context, and replace the original fragment with the corrected fragment.
[0011] Optionally, obtaining the revised segment for the finalized processing result segment includes: From the newly received streaming processing results, identify the revised version of the finalized processing result segment as the corrected segment; Alternatively, the corrected segment can be obtained based on local editing operations on the processed result segment of the finalized draft.
[0012] Optionally, saving the finalized processing result fragment as the session context includes: Determine whether the number of session contexts stored in the local cache queue has reached the preset capacity limit; If the preset capacity limit is not reached, the finalized processing result fragment will be stored in the local cache queue. If the preset capacity limit has been reached, the target session context is removed from the local cache queue based on the preset eviction policy, and the finalized processing result fragment is stored in the local cache queue.
[0013] Optionally, constructing a reconnection request based on the session context in the event of a session disconnection with the first service instance includes: If the session with the first service instance is disconnected, read the saved session context; Based on the read session context, generate a session context snapshot; The session context snapshot is encapsulated into a reconnection control frame, and the encapsulated reconnection control frame is used as the reconnection request.
[0014] Optionally, reading the saved session context when the session with the first service instance is disconnected includes: If the session with the first service instance is disconnected, obtain the attribute information of the session; The reading rule corresponding to the attribute information of the session is determined from a variety of preset reading rules; Read the saved session context according to the defined reading rules.
[0015] Optionally, the session's attribute information includes at least one of the following: The service type of the session, the reason for the session disconnection, the duration of the session, and the cumulative data volume of the session context; The preset reading rules include at least one of the following: Read all saved session contexts; Read the most recent preset number of session contexts; Read the session context that meets the preset time range.
[0016] Optionally, generating a session context snapshot based on the read session context includes: The read session context is semantically understood using a large language model to generate a semantically compressed session context. The semantically compressed session context is used as a snapshot of the session context.
[0017] Furthermore, to achieve the above objectives, this application proposes another session reconstruction method, executed by a server, the method comprising: The terminal receives a reconnection request, which is generated by the terminal when its session with the first service instance in the stateless service cluster is disconnected. The reconnection request is assigned to the second service instance in the stateless service cluster; Based on the second service instance, the session context is extracted from the reconnection request, and the session with the terminal is restored based on the session context.
[0018] Optionally, resuming the session with the terminal based on the session context includes: Establish a connection between the second service instance and the terminal, and write the extracted session context into the session context storage area corresponding to the connection; On the connection, the session with the terminal is resumed based on the content in the session context storage area.
[0019] Furthermore, to achieve the above objectives, this application also proposes a session reconstruction apparatus for use in a terminal, the apparatus comprising: The context saving module is used to save the session context during a session with the first service instance in the stateless service cluster; A request construction module is configured to construct a reconnection request based on the session context if the session with the first service instance is terminated. The request sending module is used to send the reconnection request to the server, so that the server allocates the reconnection request to a second service instance in the stateless service cluster, and the second service instance restores the session based on the session context.
[0020] Optionally, the context saving module includes: The result receiving unit is configured to receive, during a session with the first service instance, the streaming processing result returned by the first service instance in response to the streaming input data sent by the terminal. The final draft identification unit is used to identify finalized processing result segments from the streaming processing results; The final draft saving unit is used to save the finalized processing result fragment as the session context.
[0021] Optionally, the finalization identification unit is used to detect whether each processing result segment in the streaming processing result has reached a preset content boundary; and to determine the processing result segment that has reached the content boundary as a finalized processing result segment.
[0022] Optionally, the finalization identification unit is used to detect the reception time interval between each processing result segment in the streaming processing result; if the reception time interval between adjacent processing result segments exceeds a preset time threshold, the previous processing result segment in the adjacent processing result segments is determined as the finalized processing result segment.
[0023] Optionally, the context saving module further includes: The finalization modification unit is used to obtain a modified segment for the processed result segment of the finalized draft; locate the original segment corresponding to the modified segment from the storage area of the session context; and replace the original segment with the modified segment.
[0024] Optionally, the finalization modification unit is used to identify a revised version of the finalized processing result segment from the newly received streaming processing results, and use it as the corrected segment; or, based on a local editing operation on the finalized processing result segment, obtain the corrected segment.
[0025] Optionally, the finalized version saving unit is used to determine whether the number of session contexts stored in the local cache queue has reached a preset capacity limit; if the preset capacity limit has not been reached, the finalized processing result fragment is stored in the local cache queue; if the preset capacity limit has been reached, the target session context is removed from the local cache queue based on a preset eviction policy, and the finalized processing result fragment is stored in the local cache queue.
[0026] Optionally, the request construction module includes: The context reading unit is used to read the saved session context when the session with the first service instance is disconnected; A snapshot generation unit is used to generate a session context snapshot based on the read session context; The request construction unit is used to encapsulate the session context snapshot into a reconnection control frame and use the encapsulated reconnection control frame as the reconnection request.
[0027] Optionally, the context reading unit is configured to obtain the attribute information of the session when the session with the first service instance is disconnected; determine the reading rule corresponding to the attribute information of the session from a plurality of preset reading rules; and read the saved session context according to the determined reading rule.
[0028] Optionally, the session's attribute information includes at least one of the following: The service type of the session, the reason for the session disconnection, the duration of the session, and the cumulative data volume of the session context; The preset reading rules include at least one of the following: Read all saved session contexts; Read the most recent preset number of session contexts; Read the session context that meets the preset time range.
[0029] Optionally, the snapshot generation unit is used to perform semantic understanding on the read session context through a large language model to generate a semantically compressed session context; and to use the semantically compressed session context as a snapshot of the session context.
[0030] Furthermore, to achieve the above objectives, this application also proposes a session reconstruction apparatus for use on a server, the apparatus comprising: A request receiving module is used to receive a reconnection request sent by a terminal, the reconnection request being generated by the terminal when its session with the first service instance in the stateless service cluster is disconnected. The request allocation module is used to allocate the reconnection request to the second service instance in the stateless service cluster. The session recovery module is used to extract the session context from the reconnection request based on the second service instance, and to restore the session with the terminal based on the session context.
[0031] Optionally, the session recovery module is used to establish a connection between the second service instance and the terminal, and write the extracted session context into the session context storage area corresponding to the connection; on the connection, based on the content in the session context storage area, the session between the instance and the terminal is recovered.
[0032] In addition, to achieve the above objectives, this application also proposes a session reconstruction apparatus, the apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the session reconstruction method as described above.
[0033] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the session reconstruction method described above.
[0034] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the session reconstruction method described above.
[0035] One or more technical solutions proposed in this application have at least the following technical effects: The session reconstruction scheme provided in this application, during a session with the first service instance, retains the historical processing state of the session on the terminal side by storing the session context locally. If the session with the first service instance is disconnected, the terminal constructs a reconnection request based on the locally stored session context, achieving the effect of carrying the historical processing state with it and avoiding state loss due to instance switching. After the terminal sends the reconnection request to the server, the server distributes the reconnection request to the second service instance. The second service instance can then restore the session based on the session context. Thus, without centralized storage or modification of the server-side architecture, it achieves the migration and rapid reconstruction of the session context with the connection in a stateless service cluster, effectively avoiding session processing interruptions caused by service instance switching, ensuring session continuity and processing quality, while reducing system complexity and operational costs. Attached Figure Description
[0036] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0037] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 This is a schematic diagram of an implementation environment for the session reconstruction method of this application; Figure 2 This is a flowchart illustrating the first embodiment of the session reconstruction method of this application. Figure 3 This is a detailed step diagram of step S10 in the second embodiment of the session reconstruction method of this application; Figure 4 This is a detailed step diagram of step S20 in the third embodiment of the session reconstruction method of this application; Figure 5 This is a flowchart illustrating the fourth embodiment of the session reconstruction method of this application. Figure 6 This is a schematic diagram of the module structure of a session reconstruction device provided in an embodiment of this application; Figure 7 A schematic diagram of the module structure of another session reconstruction device provided in this application embodiment; Figure 8 This is a schematic diagram of the device structure of the hardware operating environment involved in the session reconstruction method in this application embodiment.
[0039] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0040] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0041] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0042] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application. See also... Figure 1 The implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network. For example, the terminal 101 is equipped with a target application provided by the server 102, and the terminal 101 can perform functions such as data transmission and message interaction through the target application.
[0043] For example, terminal 101 is a computer, mobile phone, tablet computer, or other terminal device. For example, the target application is a built-in application in the operating system of terminal 101, or an application provided by a third party. For example, the target application is a streaming interactive application such as a translation application, text summarization application, intelligent question-and-answer application, or speech-to-text application. For example, server 102 is the backend server corresponding to the target application. Server 102 is connected to a stateless service cluster, which contains multiple service instances for processing streaming service requests initiated by terminal 101.
[0044] In this application, terminal 101 is used to save the session context during a session with a first service instance in a stateless service cluster; if the session with the first service instance is disconnected, it constructs a reconnection request based on the session context and sends the reconnection request to server 102. Server 102 is used to receive the reconnection request and assign it to a second service instance in the stateless service cluster; the second service instance is used to extract the session context from the reconnection request and restore the session with terminal 101 based on the session context. Through the above cooperation, terminal 101 and server 102 collaboratively realize the cross-instance migration and rapid reconstruction of session context in the stateless service cluster.
[0045] The session reconstruction method provided in this application is applicable to various scenarios. For example, in a streaming translation scenario, terminal 101 continuously sends the text to be translated to the service instance and receives the translation results returned sentence by sentence. When network fluctuations cause the session to disconnect, terminal 101 constructs a reconnection request based on the locally saved finalized translation results. After reconnection, the new service instance can continue the previous translation progress and output, avoiding users seeing duplicate or missing translation content. As another example, in a streaming text summarization scenario, terminal 101 uploads the original text segment by segment and receives incrementally returned summary content. After disconnection and reconnection, the new service instance resumes the session based on the locally saved finalized summary fragments, ensuring the continuity and integrity of the summary output. Yet another example, in an incremental intelligent reasoning scenario, terminal 101 submits reasoning questions step by step and receives the gradually returned reasoning process and conclusions. After disconnection and reconnection, the new service instance can continue the previous reasoning state and output, avoiding the reasoning process starting from scratch.
[0046] Figure 2 This is a schematic flowchart of the first embodiment of the session reconstruction method of this application. (Refer to...) Figure 2 Taking the terminal as the executing entity as an example, the session reconstruction method includes the following steps S10~S30: Step S10: During a session with the first service instance in the stateless service cluster, save the session context.
[0047] A stateless service cluster is a distributed deployment model consisting of multiple independent service instances whose memory data is not shared, used to provide a unified service to the outside world. For example, each service instance receives client requests through load balancing, and if any service instance fails or needs to be reconnected, other service instances can take over.
[0048] The first service instance is a service instance in the stateless service cluster that the terminal initially connects to when establishing a session. For example, the service instance that the terminal is assigned to by the load balancer at the start of streaming translation, with which the terminal establishes a session and saves the session context during this period.
[0049] A session is a logical interaction process established between a terminal and a service instance to complete a continuous business task. For example, a streaming translation session between a terminal and a first service instance continuously sends the text to be translated and receives the translation result.
[0050] Session context is a collection of historical information generated during a session that is needed to resume or continue the session; for example, finalized translation result fragments, historical interaction window data, incremental processing status, etc. The terminal saves it locally and carries it to the new service instance to rebuild the processing status when reconnecting.
[0051] Step S20: If the session with the first service instance is disconnected, construct a reconnection request based on the session context.
[0052] Session disconnection refers to the interruption of the interaction between the terminal and the first service instance due to network disconnection, session timeout, or node failure.
[0053] A reconnection request is a message constructed by the terminal after a session is disconnected to request the resumption of the session. Its function is to pass the session context stored locally on the terminal to the server so that the new service instance can rebuild the session based on it.
[0054] Step S30: Send a reconnection request to the server so that the server assigns the reconnection request to the second service instance in the stateless service cluster, and the second service instance resumes the session based on the session context.
[0055] A server is an access and distribution node located between a terminal and a service instance. Examples include load balancers and API (Application Programming Interface) gateways. Its function is to receive reconnection requests sent by the terminal and distribute them to a service instance in a stateless service cluster.
[0056] The second service instance is a service instance assigned by the server after the terminal sends a reconnection request, used to take over the session processing from the first service instance. For example, the service instance assigned by the load balancer during reconnection belongs to the same stateless service cluster as the first service instance, but their memory data is not shared.
[0057] The session reconstruction scheme provided in this application, during a session with the first service instance, retains the historical processing state of the session on the terminal side by storing the session context locally. If the session with the first service instance is disconnected, the terminal constructs a reconnection request based on the locally stored session context, achieving the effect of carrying the historical processing state with it and avoiding state loss due to instance switching. After the terminal sends the reconnection request to the server, the server distributes the reconnection request to the second service instance. The second service instance can then restore the session based on the session context. Thus, without centralized storage or modification of the server-side architecture, it achieves the migration and rapid reconstruction of the session context with the connection in a stateless service cluster, effectively avoiding session processing interruptions caused by service instance switching, ensuring session continuity and processing quality, while reducing system complexity and operational costs.
[0058] Based on the first embodiment described above, a second embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description and will not be repeated hereafter. (Refer to...) Figure 3 In the second embodiment, step S10 includes steps S101 to S103: Step S101: During a session with the first service instance, receive the streaming processing result returned by the first service instance in response to the streaming input data sent by the terminal.
[0059] Streaming input data refers to the content to be processed that the terminal continuously generates and sends segment by segment to the service instance during a session. Examples include text to be translated sentence by sentence, voice data uploaded frame by frame, and original text fragments transmitted in chunks. Its characteristic is that it is generated and sent as it is sent, rather than submitted all at once.
[0060] Streaming processing results are the output content returned incrementally by a service instance after performing incremental processing on the streaming input data, as the processing progresses. For example, a translation service returns translated sentences word by word, and a summarization service returns summary text sentence by sentence. Streaming processing results include both intermediate, temporary segments that are not yet complete, and finalized segments that have been processed and will not be changed.
[0061] Step S102: Identify the finalized processing result fragments from the streaming processing results.
[0062] A processing result fragment is a single output unit segmented at a certain granularity from the streaming processing results. For example, a complete sentence, a translated paragraph, or a reasoning step are the basic units for identifying finalized content.
[0063] The finalized processing result fragments are the result fragments of the completed stage processing in the streaming processing results; for example, a complete translated sentence with punctuation at the end of the sentence, or an inference segment in the model output that marks the end of the step. The terminal stores these as trusted history locally for reconnection and recovery.
[0064] Optionally, identifying finalized processing result segments from the streaming processing results includes: detecting whether each processing result segment in the streaming processing results has reached a preset content boundary; and identifying the processing result segments that have reached the content boundary as finalized processing result segments.
[0065] Content boundaries are markers used to determine whether a processed result fragment has reached a complete semantic unit. For example, a content boundary can be a sentence-ending punctuation mark in the target language, such as a period, question mark, or exclamation mark; it can also be the end marker of a protocol frame. When a processed result fragment reaches this content boundary, it indicates that the processed result fragment can be determined as finalized.
[0066] In this embodiment, the terminal determines the finalized processing result segment by detecting whether each processing result segment reaches a preset content boundary. Since the end of each complete semantic unit in streaming output is usually accompanied by a clear content boundary, detecting this content boundary can accurately determine whether the segment has been processed, without the need for additional marking by the server. This achieves a lightweight finalized content recognition method that does not require server cooperation.
[0067] Optionally, identifying finalized processing result segments from the streaming processing results includes: detecting the reception time interval between each processing result segment in the streaming processing results; if the reception time interval between adjacent processing result segments exceeds a preset time threshold, determining the previous processing result segment in the adjacent processing result segments as the finalized processing result segment.
[0068] The receiving time interval is the time difference between the terminal receiving two adjacent processing result segments. For example, the server returns the first segment and then returns the second segment 300ms later. This 300ms is the receiving time interval, which is used to help determine whether the previous segment has been completed and output.
[0069] The preset time threshold is a pre-defined duration used by the terminal to determine whether the receiving interval is sufficient to confirm that the previous segment has been finalized, such as 300ms or 500ms. When the receiving time interval between two adjacent processed result segments exceeds this threshold, it indicates that the server pauses output after the current segment, and the previous segment has likely been completed.
[0070] In this embodiment, the terminal determines the finalized processing result segment by detecting the reception time interval between adjacent processing result segments. When the reception time interval exceeds a preset time threshold, it indicates that the previous processing result segment in the adjacent processing result segments has likely been processed and will not be changed again. This method does not depend on content format or protocol tags, is applicable to various streaming output scenarios, and has wide versatility.
[0071] Step S103: Save the finalized processing result fragment as a session context.
[0072] Optionally, the terminal stores the finalized processing result fragments as session context in a local cache queue. The local cache queue is a bounded cache structure maintained locally by the terminal for storing finalized processing result fragments. For example, a queue that stores the N most recent finalized processing result fragments in enqueue order, with new fragments enqueued and older fragments removed according to an eviction policy when the queue is full, serves as the physical carrier of the session context.
[0073] Specifically, the terminal determines whether the number of session contexts stored in the local cache queue has reached the preset capacity limit; if the preset capacity limit has not been reached, the finalized processing result fragment is stored in the local cache queue; if the preset capacity limit has been reached, the target session context is removed from the local cache queue based on the preset eviction policy, and the finalized processing result fragment is stored in the local cache queue.
[0074] The preset capacity limit is the maximum number of session contexts that the local cache queue can store; for example, it can store a maximum of 50 finalized processing result fragments to limit the storage space occupied by the cache and prevent it from growing indefinitely.
[0075] A default eviction policy is a rule used to determine which stored session context to remove when the local cache queue reaches its capacity limit. There are several ways to implement a default eviction policy. For example, a first-in, first-out (FIFO) policy removes the oldest stored fragment; a least-used (LUS) policy removes the least accessed fragment. The purpose of a default eviction policy is to ensure that the queue always contains the most recent or most important session context.
[0076] The target session context is the session context that is selected and removed according to a preset eviction policy when the capacity limit is reached; for example, the first finalized translation result stored in the queue is removed to make room for new segments.
[0077] In this embodiment, when saving a finalized processing result fragment, the terminal determines whether to store it directly or evict it before storing it by checking whether the local cache queue has reached its capacity limit. By setting a capacity limit and eviction policy, the unlimited growth of the cache and its excessive storage resource consumption are avoided, while ensuring that the queue always retains the most recently generated session context, thus achieving a balance between storage efficiency and recovery quality.
[0078] Optionally, after saving the finalized processing result fragment as a session context, the method further includes: obtaining a revised fragment for the finalized processing result fragment; locating the original fragment corresponding to the revised fragment from the storage area of the session context, and replacing the original fragment with the revised fragment.
[0079] A revised segment is a modified version of a stored, finalized processing result segment. For example, a translated sentence that the server re-reasons according to the user's correction instructions, or a summary sentence that the user manually rewrote in the terminal interface, is retrieved and used to replace the original segment to ensure that the local context is always the latest version.
[0080] The storage area is a logical or physical space on the terminal used to store saved session contexts; for example, local cache queues, memory, local databases, etc., which provide an interface for accessing and manipulating session contexts.
[0081] The original segment is the finalized processing result segment that already exists in the storage area and is targeted by the corrected segment. For example, the translated sentence "I went to the company" that the user saved before correction is the original segment before it is replaced by the corrected segment "I went to the office".
[0082] Optionally, obtaining a revised segment for a finalized processing result segment includes: identifying a revised version of the finalized processing result segment from newly received streaming processing results as a revised segment; or, obtaining the revised segment based on local editing operations on the finalized processing result segment.
[0083] The revised version is a modified output of the previously finalized processing result segment that is regenerated by the server in subsequent streaming processing; for example, after the user requests that "company" be changed to "office", the server re-translates and returns "I went to the office", and the terminal recognizes the revised version from the newly received streaming result.
[0084] Local editing operations are manual modifications made by users directly on the terminal interface to the finalized processed result segment; for example, if a user manually changes "company" to "office" in the translation result box and confirms, the terminal will obtain the corrected segment based on this editing operation.
[0085] In this embodiment, the terminal identifies the revised version from the newly received streaming results or obtains the corrected fragment based on the user's local editing operations. The former is suitable for scenarios where the server automatically pushes revisions, while the latter is suitable for scenarios where the user manually corrects the output. The two methods complement each other, improving the flexibility of obtaining the corrected fragment.
[0086] In this embodiment, after saving the finalized processing result segment, if a corrected segment is obtained, the terminal locates the original segment from the storage area and replaces it. Since users may correct the output results during a streaming session, timely updating the session context in the storage area ensures that the terminal always saves the latest version of historical information, avoiding errors in the restored session due to the use of outdated context.
[0087] In this embodiment, during a session with the first service instance, the terminal receives streaming processing results and identifies finalized processing result segments, saving only the finalized segments as session context. Since the streaming processing results contain numerous intermediate temporary segments and finalized processing result segments, filtering and retaining only finalized processing result segments avoids storage space being occupied by invalid or redundant data. This ensures that the saved session context is historical information that has been processed and finalized, providing a high-quality data foundation for efficient recovery during reconnection.
[0088] Based on the first embodiment of this application described above, a third embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description, and will not be repeated hereafter. See also... Figure 4In the third embodiment, step S20 includes steps S201 to S203.
[0089] Step S201: If the session with the first service instance is disconnected, read the saved session context.
[0090] This step refers to the terminal retrieving the saved session context from the storage area when the session with the first service instance is disconnected, so as to construct a reconnection request carrying the session context.
[0091] Optionally, if the session with the first service instance is disconnected, reading the saved session context includes: obtaining the session's attribute information; determining the reading rule corresponding to the session's attribute information from a set of preset reading rules; and reading the saved session context according to the determined reading rule.
[0092] Attribute information consists of various metadata describing session characteristics, used to guide the selection of read rules. Read rules are the selection strategies for retrieving session context from the storage area when a terminal reconnects. Read rules can be dynamically selected based on session attribute information.
[0093] Optionally, the session's attribute information includes at least one of the following: the session's business type, the reason for the session's disconnection, the session's duration, and the accumulated amount of session context data. The preset read rules include at least one of the following: reading all saved session contexts; reading the most recent preset number of session contexts; and reading session contexts that meet a preset time range.
[0094] Among them, the business type refers to the application category to which the session belongs; for example, streaming translation, streaming text summarization, and incremental intelligent reasoning. Different types of sessions have different requirements and importance for context, which can be used as the basis for selecting reading rules.
[0095] The disconnection reason is the specific reason that causes the session between the terminal and the first service instance to be interrupted; for example, network disconnection, service instance failure, session timeout. The required context scope may be different under different disconnection reasons, which can be used as the basis for selecting reading rules.
[0096] Duration is the length of time a session lasts from start to finish; for example, in a translation session that lasts for 5 minutes, the longer the duration, the more context may be accumulated, which can be used as a basis for selecting reading rules.
[0097] The cumulative data volume is the total size of the session context data saved during the session. The larger the data volume, the more necessary it is to consider selective reading rather than carrying the entire amount.
[0098] Reading all saved session contexts means reading the full session context in the storage area. For example, when the session duration is short and the accumulated data volume is small, choosing a full read ensures that the most complete historical information is available during recovery.
[0099] Reading the most recent preset number of session contexts means reading only the most recently saved session contexts in the storage area; for example, reading the most recent 20 finalized fragments is suitable for scenarios with long session durations and large amounts of data to be read in full.
[0100] Reading a session context within a preset time range refers to reading the session context saved in the storage area within a specified time period; for example, reading a finalized fragment saved within the last 5 minutes is suitable for scenarios that focus on recent history rather than the entire history.
[0101] In this embodiment, the terminal selects a suitable reading rule from various rules, such as reading all, reading the most recent preset quantity, and reading within a preset time range, based on attributes such as the session's service type, disconnection reason, duration, and accumulated data volume. By providing diverse rule options and associating them with attribute information, the terminal can flexibly adjust its reading strategy according to different scenarios, thereby achieving a better balance between session recovery quality and transmission overhead.
[0102] In this embodiment, when reading the saved session context, the terminal obtains the session's attribute information and selects the corresponding rule from a set of preset reading rules based on the attribute information. Since different sessions have different service types, disconnection reasons, durations, and other attributes, using a uniform reading rule may result in carrying too much redundant information or missing key information. By using attribute-driven dynamic rule selection, the reading strategy can be adaptively adjusted, improving the relevance and effectiveness of context carrying.
[0103] Step S202: Generate a session context snapshot based on the read session context.
[0104] Optionally, a session context snapshot is an object obtained by integrating the read session context. For example, the session context in the storage area is stored in the form of processing result fragments. After the terminal reads multiple finalized processing result fragments, it sorts and integrates these fragments to obtain an ordered session context snapshot.
[0105] Optionally, a session context snapshot is an object obtained by semantically compressing the read session context. Specifically, the read session context is semantically understood using a large language model to generate a semantically compressed session context; this semantically compressed session context is then used as a session context snapshot.
[0106] The large language model is a deep learning model deployed locally on the terminal, possessing semantic understanding and text generation capabilities. Semantic understanding is the process by which the large language model analyzes the input text to extract core semantic information. For example, the large language model understands 10 translation results, identifying key entities, relationships, and processing progress, while removing redundant content. The semantically compressed conversation context is a simplified representation of the original conversation context, retaining core semantic information to reduce data transmission volume.
[0107] In this embodiment, considering that a large language model can understand the core semantic information in the session context and remove redundant content, the large language model is used to perform semantic understanding on the read session context, generating a semantically compressed session context as a session context snapshot. Compared to mechanically truncating or carrying all saved session context, the semantically compressed session context significantly reduces the amount of data transmitted in reconnection requests while retaining key semantic information, thereby improving reconnection efficiency and recovery quality.
[0108] Step S203: Encapsulate the session context snapshot into a reconnection control frame, and use the encapsulated reconnection control frame as a reconnection request.
[0109] Among them, the reconnection control frame is a control signaling constructed by the terminal when the session is disconnected, specifically for requesting session resumption; for example, the Resume frame, unlike ordinary service request frames, explicitly carries a session context snapshot in its payload, which the server can use to identify it as a resumption request rather than a new session request.
[0110] In this embodiment, when a session is disconnected, the terminal reads the saved session context, generates a session context snapshot based on the read session context, and encapsulates it into a reconnection control frame as a reconnection request. By organizing the session context into a snapshot format, it is easier to carry and transmit it efficiently in the reconnection request; by using a dedicated reconnection control frame, context data is separated from ordinary business data, enabling the server to identify and specially process the reconnection request, thereby improving the accuracy and efficiency of reconnection processing.
[0111] Figure 5 This is a flowchart illustrating the fourth embodiment of the session reconstruction method of this application. (Refer to...) Figure 5 Taking the server as the executing entity as an example, this session reconstruction method includes the following steps S40~S60: Step S40: Receive a reconnection request sent by the terminal. The reconnection request is generated by the terminal when the session with the first service instance in the stateless service cluster is disconnected.
[0112] Step S50: Distribute the reconnection request to the second service instance in the stateless service cluster.
[0113] For example, after receiving a reconnection request from a terminal, the server first parses the request to determine whether it is a reconnection request for session recovery, rather than a regular business request. Then, the server queries the current load status of each service instance in the stateless service cluster and selects a service instance from the cluster as the allocation target according to a preset load balancing strategy. Finally, the server forwards the reconnection request to the selected service instance, which is then responsible for the subsequent session recovery processing.
[0114] It should be noted that in actual deployment, a special case exists: when the session disconnection is due to a network problem, and the first service instance itself is not faulty, the server, when allocating reconnection requests according to the load balancing strategy, may reassign the request back to the first service instance. In this case, the second service instance and the first service instance are the same instance. Under these circumstances, the first service instance also extracts the session context from the reconnection request and restores the session with the terminal based on that context. Therefore, the second service instance and the first service instance in this application can be different service instances or the same service instance; this application does not impose any restrictions on this.
[0115] Step S60: Extract the session context from the reconnection request based on the second service instance, and restore the session with the terminal based on the session context.
[0116] Optionally, restoring the session with the terminal based on the session context includes: the server establishing a connection between the second service instance and the terminal, and writing the extracted session context into the session context storage area corresponding to the connection; and restoring the session with the terminal based on the content in the session context storage area on the connection.
[0117] Here, a connection is a communication channel established between the second service instance and the terminal for resuming a session; for example, the second service instance interacts with the terminal on this connection.
[0118] The session context storage area is a memory area allocated by the second service instance for establishing new connections with the terminal, used to write the session context extracted from the reconnection request. For example, this storage area can be a context object initialized after the new connection is established. After the terminal writes a snapshot of the session context to this object, the construction of the connection-level session context is completed.
[0119] For example, before writing the session context, the second service instance can also perform a clearing operation on the session context storage area. This clearing operation ensures that there is no residual data or dirty state in the storage area, providing clean memory space for subsequent writing. After clearing is complete, the extracted session context is written to the storage area, completing the construction of the connection-level session context.
[0120] For example, the session context storage area can be reused in the default empty memory buffer. That is, after clearing the default empty memory buffer, the extracted session context is written into it, so that the buffer can simultaneously serve as the storage function of the session context.
[0121] In this embodiment, after establishing a connection with the terminal, the second service instance allocates an independent session context storage area for the connection and writes the session context extracted from the reconnection request into this storage area. Since this storage area is memory space specifically allocated for new connections, the write operation can be completed quickly, achieving rapid initialization of the session context from scratch. Based on this, the second service instance restores the session with the terminal on this connection based on the content in the storage area, enabling the new service instance to seamlessly continue the processing state of the original session, thereby ensuring session continuity.
[0122] In this embodiment, after receiving a reconnection request from a terminal, the server allocates the request to a second service instance in the stateless service cluster. Since the reconnection request carries the session context stored locally by the terminal, the second service instance directly extracts the session context from the request and restores the session with the terminal based on that context. The entire process requires no shared storage or prior negotiation between instances. By combining unified distribution by the server with direct extraction and restoration by the service instance, automatic migration of the session context within the stateless service cluster is achieved, while maintaining the lightweight deployment characteristics of independent service instances requiring no additional storage facilities.
[0123] The solution proposed in this application has at least the following beneficial effects: 1. Eliminate centralized dependencies and streamline the architecture. It eliminates the need to rely on third-party shared storage middleware such as Redis for session state synchronization, completely avoiding the problems of complex deployment, high operation and maintenance costs, high read and write latency, and single point of failure caused by centralized storage, which aligns with the lightweight and highly elastic architecture design concept of stateless services.
[0124] 2. Implement stateful continuation of stateless services Based on client-side state caching and reconnection frame migration mechanism, the problem of session context breakage caused by connection migration in multi-instance load balancing scenarios is perfectly solved, ensuring the continuity of streaming processing tasks and effectively improving the output accuracy and business stability of incremental inference and streaming processing.
[0125] 3. Wide adaptability and strong feasibility It can be implemented without modifying the server cluster architecture, simply by optimizing the client protocol and adapting the state cache. It is compatible with various multi-Pod (Kubernetes Pod, the smallest deployment unit in Kubernetes) and multi-instance distributed stateless service scenarios, and can be widely used in various real-time streaming services that require continuous session context, such as streaming translation, streaming text summarization, AI (Artificial Intelligence) incremental inference, and real-time human-computer interaction.
[0126] 4. High recovery efficiency and low cost By adopting rolling caching and on-demand snapshot carrying, only core finalized context data is transmitted, resulting in low data transmission overhead and fast local memory reconstruction of the server state, which greatly improves session reconnection and recovery efficiency and ensures low-latency business requirements.
[0127] Another point to note is that the above examples are only for understanding this application and do not constitute a limitation on the session reconstruction method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0128] This application also provides a session reconstruction apparatus for use in a terminal; please refer to [reference needed]. Figure 6 The session reconstruction device includes: The context saving module 10 is used to save the session context during a session with the first service instance in the stateless service cluster; Request construction module 20 is used to construct a reconnection request based on the session context in the event that the session with the first service instance is terminated; The request sending module 30 is used to send a reconnection request to the server so that the server can allocate the reconnection request to a second service instance in the stateless service cluster, and the second service instance can restore the session based on the session context.
[0129] Optionally, the context saving module 10 includes: The result receiving unit is used to receive, during a session with the first service instance, the streaming processing result returned by the first service instance in response to the streaming input data sent by the terminal. The final draft recognition unit is used to identify finalized processing result segments from the streaming processing results; The final draft saving unit is used to save the finalized processing result fragment as a session context.
[0130] Optionally, the finalization recognition unit is used to detect whether each processing result segment in the streaming processing result has reached the preset content boundary; and to determine the processing result segment that has reached the content boundary as the finalized processing result segment.
[0131] Optionally, the finalization identification unit is used to detect the reception time interval between each processing result segment in the streaming processing result; if the reception time interval between adjacent processing result segments exceeds a preset time threshold, the previous processing result segment in the adjacent processing result segments is determined as the finalized processing result segment.
[0132] Optionally, the context saving module 10 also includes: The final draft modification unit is used to obtain the modified fragment for the processed result fragment of the final draft; locate the original fragment corresponding to the modified fragment from the storage area of the session context, and replace the original fragment with the modified fragment.
[0133] Optionally, the finalization modification unit is used to identify a revised version of the finalized processing result segment from the newly received streaming processing results, as a corrected segment; or, based on local editing operations on the finalized processing result segment, to obtain the corrected segment.
[0134] Optionally, the finalized version saving unit is used to determine whether the number of session contexts stored in the local cache queue has reached the preset capacity limit; if the preset capacity limit has not been reached, the finalized processing result fragment is stored in the local cache queue; if the preset capacity limit has been reached, the target session context is removed from the local cache queue based on the preset eviction policy, and the finalized processing result fragment is stored in the local cache queue.
[0135] Optionally, the request constructor 20 includes: The context reading unit is used to read the saved session context when the session with the first service instance is disconnected; The snapshot generation unit is used to generate a session context snapshot based on the read session context; The request construction unit is used to encapsulate the session context snapshot into a reconnection control frame and use the encapsulated reconnection control frame as a reconnection request.
[0136] Optionally, the context reading unit is used to obtain the attribute information of the session when the session with the first service instance is disconnected; determine the reading rule corresponding to the attribute information of the session from a variety of preset reading rules; and read the saved session context according to the determined reading rule.
[0137] Optionally, the session's attribute information includes at least one of the following: The business type of the session, the reason for the session disconnection, the duration of the session, and the cumulative amount of data in the session context; The preset reading rules include at least one of the following: Read all saved session contexts; Read the most recent preset number of session contexts; Read the session context that meets the preset time range.
[0138] Optionally, the snapshot generation unit is used to perform semantic understanding on the read session context through a large language model to generate a semantically compressed session context; and to use the semantically compressed session context as a session context snapshot.
[0139] This application also provides a session reconstruction apparatus for use in a server; please refer to [reference needed]. Figure 7 The session reconstruction device includes: The request receiving module 40 is used to receive a reconnection request sent by the terminal. The reconnection request is generated by the terminal when the session with the first service instance in the stateless service cluster is disconnected. The request allocation module 50 is used to allocate reconnection requests to the second service instance in the stateless service cluster. The session recovery module 60 is used to extract the session context from the reconnection request based on the second service instance, and to restore the session with the terminal based on the session context.
[0140] Optionally, the session recovery module 60 is used to establish a connection between the second service instance and the terminal, and write the extracted session context into the session context storage area corresponding to the connection; on the connection, based on the content in the session context storage area, the session between the instance and the terminal is restored.
[0141] The session reconstruction apparatus provided in this application, employing the session reconstruction method in the above embodiments, can solve the technical problems of session processing state loss, session interruption, and service discontinuity caused by service instance switching in related technologies. Compared with the prior art, the beneficial effects of the session reconstruction apparatus provided in this application are the same as those of the session reconstruction method provided in the above embodiments, and other technical features in the session reconstruction apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0142] This application provides a session reconstruction device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the session reconstruction method in the above embodiments.
[0143] The following is for reference. Figure 8The diagram illustrates a structural schematic suitable for implementing the session reconstruction device in the embodiments of this application. The session reconstruction device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The session reconstruction device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0144] like Figure 8 As shown, the session reconstruction device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the session reconstruction device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the session reconstruction device to communicate wirelessly or wiredly with other devices to exchange data. While the figure shows session reconstruction devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0145] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0146] The session reconstruction device provided in this application, employing the session reconstruction method in the above embodiments, can solve the technical problems of session processing state loss, session interruption, and service discontinuity caused by service instance switching in related technologies. Compared with the prior art, the beneficial effects of the session reconstruction device provided in this application are the same as those of the session reconstruction method provided in the above embodiments, and other technical features in this session reconstruction device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0147] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0148] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0149] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the session reconstruction method in the above embodiments.
[0150] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0151] The aforementioned computer-readable storage medium may be included in the session reconstruction device or may exist independently and not assembled into the session reconstruction device.
[0152] The aforementioned computer-readable storage medium carries one or more programs that, when executed by the session reconstruction device, cause the session reconstruction device to: save the session context during a session with a first service instance in a stateless service cluster; construct a reconnection request based on the session context if the session with the first service instance is disconnected; and send a reconnection request to the server so that the server allocates the reconnection request to a second service instance in the stateless service cluster, and the second service instance restores the session based on the session context.
[0153] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Python, Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0154] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0155] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0156] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described session reconstruction method. This solves the technical problems of session processing state loss, session interruption, and service discontinuity caused by service instance switching in related technologies. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the session reconstruction method provided in the above embodiments, and will not be elaborated upon here.
[0157] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the session reconstruction method described above.
[0158] The computer program product provided in this application can solve the technical problems of session processing state loss, session interruption, and service discontinuity caused by service instance switching in related technologies. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the session reconstruction method provided in the above embodiments, and will not be repeated here.
[0159] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A session reconstruction method, characterized in that, The method, executed by a terminal, includes: During a session with the first service instance in the stateless service cluster, the session context is saved. If the session with the first service instance is terminated, a reconnection request is constructed based on the session context; The reconnection request is sent to the server so that the server allocates the reconnection request to a second service instance in the stateless service cluster, and the second service instance restores the session based on the session context.
2. The method as described in claim 1, characterized in that, During a session with the first service instance in the stateless service cluster, the session context is saved, including: During a session with the first service instance, receive the streaming processing result returned by the first service instance in response to the streaming input data sent by the terminal; From the streaming processing results, identify the finalized processing result segments; The finalized processing result fragment is saved as the session context.
3. The method as described in claim 2, characterized in that, The step of identifying the finalized processing result fragment from the streaming processing results includes: Detect whether each processing result segment in the streaming processing result reaches the preset content boundary; The processing result fragment that reaches the content boundary is identified as the finalized processing result fragment.
4. The method as described in claim 2, characterized in that, The step of identifying the finalized processing result fragment from the streaming processing results includes: Detect the receiving time interval between each processing result segment in the streaming processing result; If the receiving time interval between adjacent processing result segments exceeds a preset time threshold, the previous processing result segment in the adjacent processing result segments will be determined as the finalized processing result segment.
5. A session reconstruction method, characterized in that, The method, executed by the server, includes: The terminal receives a reconnection request, which is generated by the terminal when its session with the first service instance in the stateless service cluster is disconnected. The reconnection request is assigned to the second service instance in the stateless service cluster; Based on the second service instance, the session context is extracted from the reconnection request, and the session with the terminal is restored based on the session context.
6. A session reconstruction apparatus, characterized in that, Applied to a terminal, the device includes: The context saving module is used to save the session context during a session with the first service instance in the stateless service cluster; A request construction module is configured to construct a reconnection request based on the session context if the session with the first service instance is terminated. The request sending module is used to send the reconnection request to the server, so that the server allocates the reconnection request to a second service instance in the stateless service cluster, and the second service instance restores the session based on the session context.
7. A session reconstruction device, characterized in that, Applied to a server, the device includes: A request receiving module is used to receive a reconnection request sent by a terminal, the reconnection request being generated by the terminal when its session with the first service instance in the stateless service cluster is disconnected. The request allocation module is used to allocate the reconnection request to the second service instance in the stateless service cluster. The session recovery module is used to extract the session context from the reconnection request based on the second service instance, and to restore the session with the terminal based on the session context.
8. A session reconstruction device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the session reconstruction method as described in any one of claims 1 to 5.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the session reconstruction method as described in any one of claims 1 to 5.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the session reconstruction method as described in any one of claims 1 to 5.
