001/*
002 * Copyright 2022-2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.soklet;
018
019import org.jspecify.annotations.NonNull;
020
021import java.time.Instant;
022import java.util.Optional;
023
024/**
025 * Read-only identity and metadata for a streaming HTTP response.
026 *
027 * @author <a href="https://www.revetkn.com">Mark Allen</a>
028 */
029public interface StreamingResponseHandle {
030        /**
031         * The server type that wrote the stream.
032         *
033         * @return the server type
034         */
035        @NonNull
036        ServerType getServerType();
037
038        /**
039         * The request associated with the stream.
040         *
041         * @return the request
042         */
043        @NonNull
044        Request getRequest();
045
046        /**
047         * The resource method associated with the stream, if available.
048         *
049         * @return the resource method, or {@link Optional#empty()} if unavailable
050         */
051        @NonNull
052        Optional<ResourceMethod> getResourceMethod();
053
054        /**
055         * The streaming response.
056         *
057         * @return the streaming response
058         */
059        @NonNull
060        MarshaledResponse getMarshaledResponse();
061
062        /**
063         * Returns the moment at which this stream was established.
064         *
065         * @return the stream establishment moment
066         */
067        @NonNull
068        Instant getEstablishedAt();
069}