Interface Transport

  • All Known Implementing Classes:
    OkHttpTransport

    public interface Transport
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_REQUEST_SIZE  
    • Method Summary

      Modifier and Type Method Description
      void close()  
      Response roundTrip​(Request request)
      Performs an HTTP request using the given request object.
      EventStream stream​(Request request)
      Opens a Server-Sent Event (SSE) stream.
    • Method Detail

      • roundTrip

        Response roundTrip​(Request request)
                    throws Exception
        Performs an HTTP request using the given request object. If the request results in a Stitch service error, the caller is responsible for calling StitchError.handleRequestError(Response) to decode the exception, as this method will not throw the service exception.
        Parameters:
        request - The HTTP request to perform.
        Returns:
        The response to the request.
        Throws:
        Exception - if the request fails in transport for any reason. This will not be a StitchServiceException, since those must be decoded by the caller.
      • stream

        EventStream stream​(Request request)
                    throws IOException,
                           StitchServiceException
        Opens a Server-Sent Event (SSE) stream. See https://www.w3.org/TR/2009/WD-eventsource-20090421/ for specification details. If the underlying request to the Stitch server results in a service exception, this function will detect it and throw it, unlike the roundTrip(Request) method.
        Parameters:
        request - The request to open the stream.
        Returns:
        A raw EventStream representing the opened change stream.
        Throws:
        IOException - if the request fails to due to an I/O error
        StitchServiceException - if the request to the Stitch server was completed, but the stream could not be opened due to a Stitch error (such as "InvalidSession").
      • close

        void close()