Module: Quark::Quark

Defined in:
lib/quark.rb,
lib/quark/os.rb,
lib/quark/spi.rb,
lib/quark/mock.rb,
lib/quark/test.rb,
lib/quark/error.rb,
lib/quark/logging.rb,
lib/quark/reflect.rb,
lib/quark/spi_api.rb,
lib/quark/behaviors.rb,
lib/quark/concurrent.rb,
lib/quark/spi_api_tracing.rb

Defined Under Namespace

Modules: Behaviors, Concurrent, Error, Logging, Mock, Os, Reflect, Spi, SpiApi, SpiApiTracing, Test Classes: BaseService, BoundMethod, CallIfIsInstance, Callback, CallbackEvent, ChainPromise, Client, DegenerateResolver, HTTPError, HTTPHandler, HTTPRequest, HTTPResponse, HTTPServlet, IO, IOHTTPHandler, IOScheduleTask, ListUtil, Maybe, ParsedInt, ParsedLong, ParsedNumber, Passthrough, Promise, PromiseFactory, PromiseValue, Resolver, ResponseHolder, Runtime, Server, ServerResponder, Service, ServiceInstance, Servlet, ServletError, Task, URL, UnaryCallable, WSError, WSHandler, WSServlet, WebSocket

Class Method Summary collapse

Class Method Details

._BoundMethodObject



3384
# File 'lib/quark.rb', line 3384

def self._BoundMethod; BoundMethod; end

._CallbackObject



2742
# File 'lib/quark.rb', line 2742

def self._Callback; Callback; end

._CallbackEventObject



2630
# File 'lib/quark.rb', line 2630

def self._CallbackEvent; CallbackEvent; end

._CallIfIsInstanceObject



2877
# File 'lib/quark.rb', line 2877

def self._CallIfIsInstance; CallIfIsInstance; end

._ChainPromiseObject



2565
# File 'lib/quark.rb', line 2565

def self._ChainPromise; ChainPromise; end

._getLogger(topic) ⇒ Object



708
709
710
711
712
713
714
715
716
717
# File 'lib/quark.rb', line 708

def self._getLogger(topic)
    
    if (::Quark.quark.logging.Config._autoconfig())
        ::Quark.quark.logging.makeConfig().configure()
    end
    return ::Quark.quark.concurrent.Context.runtime().logger(topic)


    nil
end

._IOHTTPHandlerObject



3531
# File 'lib/quark.rb', line 3531

def self._IOHTTPHandler; IOHTTPHandler; end

._IOScheduleTaskObject



3467
# File 'lib/quark.rb', line 3467

def self._IOScheduleTask; IOScheduleTask; end

._PassthroughObject



2822
# File 'lib/quark.rb', line 2822

def self._Passthrough; Passthrough; end

.BaseServiceObject



1212
# File 'lib/quark.rb', line 1212

def self.BaseService; BaseService; end

.behaviorsObject



5
# File 'lib/quark/behaviors.rb', line 5

def self.behaviors; Behaviors; end

.callUnaryCallable(callee, arg) ⇒ Object

Allow native code to call UnaryCallables.



699
700
701
702
703
704
705
# File 'lib/quark.rb', line 699

def self.callUnaryCallable(callee, arg)
    
    return (callee).call(arg)


    nil
end

.ClientObject



1454
# File 'lib/quark.rb', line 1454

def self.Client; Client; end

.concurrentObject



5
# File 'lib/quark/concurrent.rb', line 5

def self.concurrent; Concurrent; end

.DegenerateResolverObject



1396
# File 'lib/quark.rb', line 1396

def self.DegenerateResolver; DegenerateResolver; end

.errorObject



5
# File 'lib/quark/error.rb', line 5

def self.error; Error; end

.fromJSON(cls, result, json) ⇒ Object

deserialize json into provided result object. Skip over fields starting with underscore



809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
# File 'lib/quark.rb', line 809

def self.fromJSON(cls, result, json)
    
    if ((((json) == (nil)) || (json.isNull())) || (json.isUndefined()))
        return nil
    end
    idx = 0
    genericNumber = false
    if (((cls) == (nil)) || (cls.isAbstract()))
        type = json.getType()
        if ((type) == ("boolean"))
            cls = ::Quark.quark.reflect.QuarkClass.BOOL
        end
        if ((type) == ("number"))
            cls = ::Quark.quark.reflect.QuarkClass.FLOAT
            genericNumber = true
        end
        if ((type) == ("string"))
            cls = ::Quark.quark.reflect.QuarkClass.STRING
        end
        if ((type) == ("list"))
            if ((result) == (nil))
                result = ::DatawireQuarkCore::List.new([])
            end
            cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(result))
        end
        if ((type) == ("object"))
            klazz = (json).getObjectItem("$class").getString()
            if ((klazz) != (nil))
                cls = ::Quark.quark.reflect.QuarkClass.get(klazz)
            else
                if ((result) == (nil))
                    result = {}
                end
                cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(result))
            end
        end
    end
    if ((result) == (nil))
        if (((cls).name) == ("quark.String"))
            s = json.getString()
            return s
        end
        if (((cls).name) == ("quark.float"))
            flt = json.getNumber()
            if (genericNumber)
                if (((flt).round()) == (flt))
                    l2 = (json.getNumber()).round()
                    return l2
                end
            end
            return flt
        end
        if (((cls).name) == ("quark.int"))
            i = (json).getNumber.round
            return i
        end
        if (((cls).name) == ("quark.long"))
            l = (json.getNumber()).round()
            return l
        end
        if (((cls).name) == ("quark.bool"))
            b = json.getBool()
            return b
        end
        result = cls.construct(::DatawireQuarkCore::List.new([]))
    end
    if (((cls).name) == ("quark.List"))
        qlist = ::DatawireQuarkCore.cast(result) { ::DatawireQuarkCore::List }
        while ((idx) < (json.size())) do
            (qlist) << (::Quark.quark.fromJSON((cls.getParameters())[0], nil, json.getListItem(idx)))
            idx = (idx) + (1)
        end
        return qlist
    end
    if (((cls).name) == ("quark.Map"))
        map = ::DatawireQuarkCore.cast(result) { ::Hash }
        keys = json.keys()
        while ((idx) < ((keys).size)) do
            key = (keys)[idx]
            value = (json).getObjectItem(key)
            if ((key) != ("$map"))
                (map)[key] = (::Quark.quark.fromJSON((cls.getParameters())[1], nil, value))
            else
                hashIdx = 0
                while ((hashIdx) < (value.size())) do
                    hkey = ::Quark.quark.fromJSON((cls.getParameters())[0], nil, value.getListItem(hashIdx))
                    hvalue = ::Quark.quark.fromJSON((cls.getParameters())[1], nil, value.getListItem((hashIdx) + (1)))
                    (map)[hkey] = (hvalue)
                    hashIdx = (hashIdx) + (2)
                end
            end
            idx = (idx) + (1)
        end
    end
    fields = cls.getFields()
    while ((idx) < ((fields).size)) do
        f = (fields)[idx]
        idx = (idx) + (1)
        if (((f).name).start_with?("_"))
            next
        end
        if (((json).getObjectItem((f).name).isDefined()) && (!((json).getObjectItem((f).name).isNull())))
            (result)._setField(((f).name), (::Quark.quark.fromJSON(f.getType(), nil, (json).getObjectItem((f).name))))
        end
    end
    return result


    nil
end

.HTTPErrorObject



1871
# File 'lib/quark.rb', line 1871

def self.HTTPError; HTTPError; end

.HTTPHandlerObject



1926
# File 'lib/quark.rb', line 1926

def self.HTTPHandler; HTTPHandler; end

.HTTPRequestObject



1981
# File 'lib/quark.rb', line 1981

def self.HTTPRequest; HTTPRequest; end

.HTTPResponseObject



2056
# File 'lib/quark.rb', line 2056

def self.HTTPResponse; HTTPResponse; end

.HTTPServletObject



2125
# File 'lib/quark.rb', line 2125

def self.HTTPServlet; HTTPServlet; end

.IOObject



3616
# File 'lib/quark.rb', line 3616

def self.IO; IO; end

.ListUtilObject



592
# File 'lib/quark.rb', line 592

def self.ListUtil; ListUtil; end

.loggingObject



5
# File 'lib/quark/logging.rb', line 5

def self.logging; Logging; end

.MaybeObject



216
# File 'lib/quark.rb', line 216

def self.Maybe; Maybe; end

.mockObject



5
# File 'lib/quark/mock.rb', line 5

def self.mock; Mock; end

.nowObject

Get epoch time in milliseconds



185
186
187
188
189
190
191
# File 'lib/quark.rb', line 185

def self.now()
    
    return ::Quark.quark.concurrent.Context.runtime().now()


    nil
end

.osObject



5
# File 'lib/quark/os.rb', line 5

def self.os; Os; end

.ParsedIntObject



393
# File 'lib/quark.rb', line 393

def self.ParsedInt; ParsedInt; end

.ParsedLongObject



505
# File 'lib/quark.rb', line 505

def self.ParsedLong; ParsedLong; end

.ParsedNumberObject



255
# File 'lib/quark.rb', line 255

def self.ParsedNumber; ParsedNumber; end

.PromiseObject



3063
# File 'lib/quark.rb', line 3063

def self.Promise; Promise; end

.PromiseFactoryObject



3304
# File 'lib/quark.rb', line 3304

def self.PromiseFactory; PromiseFactory; end

.PromiseValueObject



2953
# File 'lib/quark.rb', line 2953

def self.PromiseValue; PromiseValue; end

.reflectObject



5
# File 'lib/quark/reflect.rb', line 5

def self.reflect; Reflect; end

.ResolverObject



1036
# File 'lib/quark.rb', line 1036

def self.Resolver; Resolver; end

.ResponseHolderObject



1069
# File 'lib/quark.rb', line 1069

def self.ResponseHolder; ResponseHolder; end

.RuntimeObject



53
# File 'lib/quark.rb', line 53

def self.Runtime; Runtime; end

.ServerObject



1737
# File 'lib/quark.rb', line 1737

def self.Server; Server; end

.ServerResponderObject



1647
# File 'lib/quark.rb', line 1647

def self.ServerResponder; ServerResponder; end

.ServiceObject



1159
# File 'lib/quark.rb', line 1159

def self.Service; Service; end

.ServiceInstanceObject



1289
# File 'lib/quark.rb', line 1289

def self.ServiceInstance; ServiceInstance; end

.ServletObject



976
# File 'lib/quark.rb', line 976

def self.Servlet; Servlet; end

.ServletErrorObject



921
# File 'lib/quark.rb', line 921

def self.ServletError; ServletError; end

.sleep(seconds) ⇒ Object

Suspend execution of this thread for some number of seconds



196
197
198
199
200
201
202
# File 'lib/quark.rb', line 196

def self.sleep(seconds)
    
    ::Quark.quark.concurrent.Context.runtime().sleep(seconds)


    nil
end

.spiObject



5
# File 'lib/quark/spi.rb', line 5

def self.spi; Spi; end

.spi_apiObject



5
# File 'lib/quark/spi_api.rb', line 5

def self.spi_api; SpiApi; end

.spi_api_tracingObject



5
# File 'lib/quark/spi_api_tracing.rb', line 5

def self.spi_api_tracing; SpiApiTracing; end

.TaskObject



20
# File 'lib/quark.rb', line 20

def self.Task; Task; end

.testObject



5
# File 'lib/quark/test.rb', line 5

def self.test; Test; end

.toJSON(obj, cls) ⇒ Object

Serializes object tree into JSON. skips over fields starting with underscore



724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/quark.rb', line 724

def self.toJSON(obj, cls)
    
    result = ::DatawireQuarkCore::JSONObject.new
    if ((obj) == (nil))
        result.setNull()
        return result
    end
    if (((cls) == (nil)) || (cls.isAbstract()))
        cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(obj))
    end
    idx = 0
    if (((cls).name) == ("quark.String"))
        result.setString(::DatawireQuarkCore.cast(obj) { ::String })
        return result
    end
    if (((((((cls).name) == ("quark.byte")) || (((cls).name) == ("quark.short"))) || (((cls).name) == ("quark.int"))) || (((cls).name) == ("quark.long"))) || (((cls).name) == ("quark.float")))
        result.setNumber(obj)
        return result
    end
    if (((cls).name) == ("quark.List"))
        result.setList()
        qlist = ::DatawireQuarkCore.cast(obj) { ::DatawireQuarkCore::List }
        while ((idx) < ((qlist).size)) do
            result.setListItem(idx, ::Quark.quark.toJSON((qlist)[idx], nil))
            idx = (idx) + (1)
        end
        return result
    end
    if (((cls).name) == ("quark.Map"))
        result.setObject()
        map = ::DatawireQuarkCore.cast(obj) { ::Hash }
        keys = ::DatawireQuarkCore::List.new((map).keys)
        key = nil
        strKey = nil
        keyMap = {}
        strKeys = ::DatawireQuarkCore::List.new([])
        while ((idx) < ((keys).size)) do
            key = (keys)[idx]
            strKey = (key).to_s
            strKey = ::Quark.quark.toJSON(key, (cls.getParameters())[0]).toString()
            (keyMap)[strKey] = (key)
            (strKeys) << (strKey)
            idx = (idx) + (1)
        end
        (strKeys).sort!
        idx = 0
        hash = ::DatawireQuarkCore.cast(nil) { ::DatawireQuarkCore::JSONObject }
        hashIdx = 0
        while ((idx) < ((strKeys).size)) do
            strKey = (strKeys)[idx]
            key = (keyMap)[strKey]
            value = (map)[key]
            if (((::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(key))).name) == ("quark.String"))
                (result).setObjectItem((::DatawireQuarkCore.cast(key) { ::String }), (::Quark.quark.toJSON(value, (cls.getParameters())[1])))
            else
                if ((hash) == (nil))
                    hash = ::DatawireQuarkCore::JSONObject.new.setList()
                    (result).setObjectItem(("$map"), (hash))
                end
                hash.setListItem(hashIdx, ::Quark.quark.toJSON(key, (cls.getParameters())[0]))
                hash.setListItem((hashIdx) + (1), ::Quark.quark.toJSON(value, (cls.getParameters())[1]))
                hashIdx = (hashIdx) + (2)
            end
            idx = (idx) + (1)
        end
        return result
    end
    (result).setObjectItem(("$class"), (::DatawireQuarkCore::JSONObject.new.setString((cls).id)))
    fields = cls.getFields()
    while ((idx) < ((fields).size)) do
        fieldName = ((fields)[idx]).name
        if (!((fieldName).start_with?("_")))
            (result).setObjectItem((fieldName), (::Quark.quark.toJSON((obj)._getField(fieldName), (fields)[idx].getType())))
        end
        idx = (idx) + (1)
    end
    return result


    nil
end

.UnaryCallableObject



663
# File 'lib/quark.rb', line 663

def self.UnaryCallable; UnaryCallable; end

.URLObject



2419
# File 'lib/quark.rb', line 2419

def self.URL; URL; end

.uuidObject

Get a v4 random UUID (Universally Unique IDentifier)



207
208
209
210
211
212
213
# File 'lib/quark.rb', line 207

def self.uuid()
    
    return ::Quark.quark.concurrent.Context.runtime().uuid()


    nil
end

.WebSocketObject



2325
# File 'lib/quark.rb', line 2325

def self.WebSocket; WebSocket; end

.WSErrorObject



2173
# File 'lib/quark.rb', line 2173

def self.WSError; WSError; end

.WSHandlerObject



2228
# File 'lib/quark.rb', line 2228

def self.WSHandler; WSHandler; end

.WSServletObject



2370
# File 'lib/quark.rb', line 2370

def self.WSServlet; WSServlet; end