![]() Public, protected, and private are accessĭescriptors used to convey how and when the class or class member should be used. Access Levelsįramework classes or their members may be specified as private or protected. The alias/xtype is listed next to the class name ofĪpplicable classes for quick reference. The shortcut name is referred to as an alias (or xtype if theĬlass extends Ext.Component). Many classes have shortcut names used when creating (instantiating) a class with aĬonfiguration object. Local socket = require( "socket") - gettime() has higher precision than os.Contents Terms, Icons, and Labels Access Levels Member Types Member Syntax Member Flags Class Icons Member Icons Navigation and Features Class Member Quick-Nav Menu Getter and Setter Methods History Bar Search and Filters API Doc Class Metadata Expanding and Collapsing Examples and Class Members Desktop -vs- Mobile View Viewing the Class Source Terms, Icons, and Labels use os.time(): this only offers resolution to one second (used when.use luasocket gettime() function, but it only does so when LuaSocket.It should ideally be called from the init_worker context. if in ngx_lua, use ngx.time() + () to ensure a unique seedįor each worker.Print( "here's a new uuid: ",uuid()) seed () Local socket = require( "socket") - gettime() has higher precision than os.time() The random seed to set (integer from 0 - 2^32, negative values will be made positive) This improved version drops the most significantīits in those cases to get the seed within the proper range again. If this happens, the seed will be 0 or 1 and all randomness willīe gone (each application run will generate the same sequence of random Lua 5.1 and 5.2 both truncate the seed given if it exceeds the integer Print( "here's a new uuid: ",uuid()) randomseed (seed) If omitted, a fully randomized uuid will be generated, but then you must ensure that the random seed is set properly! (optional) string containing a unique hex value (e.g.: 00:0c:29:69:41:c6), to be used to compensate for the lesser math_random() function. my_uuid = uuid(my_networkcard_macaddress) use uuid without luasocket, and request a uuid using an unique hex string,Įg.use uuid without luasocket, set a random seed using uuid.randomseed(some_good_seed),Īnd request a uuid using no parameter, eg.first require luasocket, then call ed(), and request a uuid using no.The module table itself is a shortcut to thisįunction, so my_uuid = uuid.new() equals my_uuid = uuid(). Either provide a unique hex string, or make sure the And to not have multiple processes do thatĬreates a new uuid. So make sure to seed only once, application wide. Specifically when used from multiple processes. It demonstrates the problem of using time as a random seed. Hence setting it isĪn application level responsibility, libraries should never set it! Important: the random seed is a global piece of data. If available and hence reduce that problem (provided LuaSocket has been loaded before uuid). Regarding the above mention on os.time() the modifications use the socket.gettime() function from LuaSocket It represents the mac address.Ģ modified by Thijs Schreijer from the original Rackspace code as a generic Lua module. Is solved by using the node field from a version 1 UUID. To guarantee spacial uniqueness when two hosts generate a uuid after being seeded during the same second. ![]() ![]() Since os.time() precision is only 1 second, it would be hard Note that this is not a true version 4 (random) UUID. See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Unless required by applicable law or agreed to in writing, softwareĭistributed under the License is distributed on an "AS-IS" BASIS, You may not use this file except in compliance with the License. Licensed under the Apache License, Version 2.0 (the "License") Copyright 2012 Rackspace (original), 2013-2021 Thijs Schreijer (modifications)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |