kra8 / laravel-snowflake Goto Github PK
View Code? Open in Web Editor NEWThis Laravel package to generate 64 bit identifier like the snowflake within Twitter.
License: MIT License
This Laravel package to generate 64 bit identifier like the snowflake within Twitter.
License: MIT License
Hey great package!
Is it possible to configure the generator to create only 16 or 15 digit numbers?
I'm pushing my Eloquent collections to Vue components and Javascript's Number.MAX_SAFE_INTEGER
is only 16 digits, thus all the IDs are getting rounded and no longer match the actual db ID.
Thanks
Hello,
I use your package in php-fpm mode, and the generated id will be repeated under large concurrent requests.
$router->get('/snowflake',function(){ $snowflake = app('Kra8\Snowflake\Snowflake'); $id = $snowflake->next(); file_put_contents(storage_path().'/ids.txt',$id."\n",FILE_APPEND); });
and use ab test
ab -c100 -n1000 http://dev.v8.com/snowflake
It will generate duplicate ids
I'm getting this message in my logs.
Implicit conversion from float 1651699585.045 to int loses precision in /vendor/kra8/laravel-snowflake/src/Snowflake.php on line 141
This is row 141:
$datetime = date('Y-m-d H:i:s', ((($timestamp + $this->epoch) / 1000) | 0));
Ideas? I'm running PHP 8.1.4. Thanks!
Using version ^1.3 for kra8/laravel-snowflake
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install kra8/laravel-snowflake v1.3.2
- Conclusion: don't install kra8/laravel-snowflake v1.3.1
- Conclusion: remove laravel/framework v7.4.0
- Installation request for kra8/laravel-snowflake ^1.3 -> satisfiable by kra8/laravel-snowflake[v1.3.0, v1.3.1, v1.3.2].
- Conclusion: don't install laravel/framework v7.4.0
- kra8/laravel-snowflake v1.3.0 requires illuminate/support ^6.0 -> satisfiable by illuminate/support[6.x-dev, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.2, v6.18.3, v6.18.4, v6.18.5, v6.2.0, v6.3.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0].
- don't install illuminate/support 6.x-dev|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.0.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.0.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.0.2|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.0.3|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.0.4|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.1.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.10.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.11.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.12.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.13.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.13.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.14.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.15.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.15.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.16.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.17.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.17.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.2|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.3|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.4|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.18.5|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.2.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.3.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.4.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.5.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.5.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.5.2|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.6.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.6.1|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.6.2|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.7.0|don't install laravel/framework v7.4.0
- don't install illuminate/support v6.8.0|don't install laravel/framework v7.4.0
- Installation request for laravel/framework (locked at v7.4.0, required as ^7.0) -> satisfiable by laravel/framework[v7.4.0].
Installation failed, reverting ./composer.json to its original content.
Hi, I have a problem, I am using Laravel Jetstream with the Livewire stack, everything is working fine except one thing.
When I try to update a Model, Livewire gives me an error
Livewire encountered corrupt data when trying to hydrate the [legal-entities.edit-page] component. Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests.
After some digging I found out, that the ids for the model are not matching!
Lets say the model has an id of 432224099704639488
but in the error, under Livewire serverMemo, it says, it has an id of 432224099704639500
, a very small difference. How can that be? There is no model with the id of 432224099704639500
.
Do you have a clue what is going on?
Hello,
I use shortflakes in my app due to compatibility with laravel nova and some other apps (it is just simpler in Javascript API clients) and I wonder that Shortflakes use WORKER_ID and DATACENTER_ID from config?
In this code:
laravel-snowflake/src/Snowflake.php
Lines 132 to 135 in 0f517d4
toSnowflakeId
method.
So how Shortflake works for now, what are benefits from using shortflakes?
Best
I want to point it out, current solution deppends on random sequence resolver, which is usually not the best option.
It works well when IDs are generated by 1 process, but there's no way to guarantee overlap of the IDs, when several different processes will generate the ID. That is the case when your application runs on webserver. Each request has their own unique information about the class constructor.
Consider using https://github.com/godruoyi/php-snowflake with https://github.com/kra8/laravel-snowflake instead to make it more maintainable and flexible.
I would say, currently it's not the best to use kra8/laravel-snowflake on high traffic web application.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.