Class InsertsPublisher

    • Field Detail


        public static final int DEFAULT_BUFFER_MAX_SIZE
        The buffer max size indicator value used by the default constructor. See InsertsPublisher(int) for how this value is used.
        See Also:
        Constant Field Values
    • Constructor Detail

      • InsertsPublisher

        public InsertsPublisher()
        Creates an InsertsPublisher.
      • InsertsPublisher

        public InsertsPublisher​(int bufferMaxSize)
        Creates an InsertsPublisher.
        bufferMaxSize - Indicative max number of elements to store in the buffer. Note that this value is not enforced, but it used to determine what to return from the accept(KsqlObject) method so the caller can stop sending more rows and set a drainHandler to be notified when the buffer is cleared
    • Method Detail

      • accept

        public boolean accept​(KsqlObject row)
        Provides a new row for insertion. The publisher will attempt to deliver it to server endpoint, once the Client.streamInserts(java.lang.String, org.reactivestreams.Publisher<io.confluent.ksql.api.client.KsqlObject>) request has been made. The publisher will buffer the row internally if it can't deliver it immediately. Note that the row will be buffered even if the buffer is 'full', i.e., if number of elements is at least bufferMaxSize, as the bufferMaxSize value is not a hard limit. See InsertsPublisher(int) for more.
        row - the row to insert
        whether the internal buffer is 'full', i.e., if number of elements is at least bufferMaxSize.
      • drainHandler

        public void drainHandler​(Runnable handler)
        Sets a drain handler on the publisher. The drain handler will be called if after a row is delivered there are zero elements buffered internally and there is demand from the subscriber for more elements. Drain handlers may be used in combination with the return value from accept(KsqlObject) to ensure the publisher's buffer does not grow too large.

        Drain handlers are one shot handlers; after a drain handler is called it will never be called again. Instead, the caller should set a new drain handler for subsequent use.

        handler - the drain handler
      • subscribe

        public void subscribe​(org.reactivestreams.Subscriber<? super KsqlObject> subscriber)
        Specified by:
        subscribe in interface org.reactivestreams.Publisher<KsqlObject>