Sha256: a46f67b3bc1500638c0c3b749e13bd7d26d05f957af6b28d57fed9585402a60f

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

module Orchestrator
    module Service
        module Mixin
            include ::Orchestrator::Core::Mixin

            def request(method, path, options = {}, &blk)
                defer = @__config__.thread.defer
                options[:method] = method
                options[:path] = path
                options[:defer] = defer
                options[:max_waits] = 0  # HTTP will only ever respond to a request
                options[:on_receive] = blk if blk     # on command success
                @__config__.thread.schedule do
                    @__config__.processor.queue_command(options)
                end
                defer.promise
            end

            def get(path, options = {}, &blk)
                request(:get, path, options, &blk)
            end

            def post(path, options = {}, &blk)
                request(:post, path, options, &blk)
            end

            def put(path, options = {}, &blk)
                request(:put, path, options, &blk)
            end

            def delete(path, options = {}, &blk)
                request(:delete, path, options, &blk)
            end

            def config(options)
                @__config__.thread.schedule do
                    @__config__.processor.config = options
                end
            end

            def defaults(options)
                @__config__.thread.schedule do
                    @__config__.processor.send_options(options)
                end
            end

            def clear_cookies
                # TODO::
            end

            def use_middleware(klass)
                # TODO::
            end
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orchestrator-1.0.3 lib/orchestrator/service/mixin.rb
orchestrator-1.0.2 lib/orchestrator/service/mixin.rb
orchestrator-1.0.1 lib/orchestrator/service/mixin.rb