@ -1,6 +1,6 @@  
			
		 
		
	
		
			
			 
			 
			
			 
			
			# crystal-scatter  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			TODO: Write a description here  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			## Installation  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -9,7 +9,8 @@ Add this to your application's `shard.yml`:  
			
		 
		
	
		
			
			 
			 
			
			 
			
			```yaml  
			
		 
		
	
		
			
			 
			 
			
			 
			
			dependencies:  
			
		 
		
	
		
			
			 
			 
			
			 
			
			  crystal-scatter:  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    github: your-github-user/crystal-scatter  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    git: https://git.nekoit.xyz/Archivist/sales_backend  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    version: ~> 0.1.0  
			
		 
		
	
		
			
			 
			 
			
			 
			
			```  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			## Usage  
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -18,15 +19,34 @@ dependencies:  
			
		 
		
	
		
			
			 
			 
			
			 
			
			require "crystal-scatter"  
			
		 
		
	
		
			
			 
			 
			
			 
			
			```  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			TODO: Write usage instructions here  
			
		 
		
	
		
			
			 
			 
			
			 
			
			Create a MetaRing and add services to it, using the weights as a mark of the load the service can handle (example: number of threads each CPU of the servers can handle).  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			## Development  
			
		 
		
	
		
			
			 
			 
			
			 
			
			```crystal  
			
		 
		
	
		
			
			 
			 
			
			 
			
			client_ip = "185.124.235.1"  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			ring = Crystal::Scatter::MetaRing.new(3)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			ring.add [  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Crystal::Scatter::Daemon (8 ,    [0,0,0,0,0,0], "https://api01.myservice.com"),  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Crystal::Scatter::Daemon (16,    [0,0,0,0,1,0], "https://api02.myservice.com"),  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Crystal::Scatter::Daemon (12,    [1,0,0,0,0,0], "https://api03.myservice.com"),  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Crystal::Scatter::Daemon (12,    [1,0,0,0,1,0], "https://api04.myservice.com"),  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Crystal::Scatter::Daemon (12,    [2,0,0,0,0,0], "https://api05.myservice.com")  
			
		 
		
	
		
			
			 
			 
			
			 
			
			]  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			ring.get_slices_for(client_ip)   
			
		 
		
	
		
			
			 
			 
			
			 
			
			# => [  
			
		 
		
	
		
			
			 
			 
			
			 
			
			#       "https://api01.myservice.com",  
			
		 
		
	
		
			
			 
			 
			
			 
			
			#       "https://api03.myservice.com",  
			
		 
		
	
		
			
			 
			 
			
			 
			
			#       "https://api05.myservice.com"  
			
		 
		
	
		
			
			 
			 
			
			 
			
			#    ]  
			
		 
		
	
		
			
			 
			 
			
			 
			
			```  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			TODO: Write development instructions here  
			
		 
		
	
		
			
			 
			 
			
			 
			
			The output will provide you information to contact the service in a balanced way.   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			## Contributing  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			1. Fork it (< https: / / github . com / your-github-user / crystal-scatter / fork > )  
			
		 
		
	
		
			
			 
			 
			
			 
			
			1. [Fork it ](https://git.nekoit.xyz/repo/fork/18  )  
			
		 
		
	
		
			
			 
			 
			
			 
			
			2. Create your feature branch (`git checkout -b my-new-feature`)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			3. Commit your changes (`git commit -am 'Add some feature'`)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			4. Push to the branch (`git push origin my-new-feature`)  
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -34,4 +54,6 @@ TODO: Write development instructions here  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			## Contributors  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			- [your-github-user ](https://github.com/your-github-user ) Ludovic 'Archivist' Lagouardette - creator, maintainer  
			
		 
		
	
		
			
			 
			 
			
			 
			
			- Ludovic 'Archivist' Lagouardette - creator, maintainer  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    - [Gitea ](https://git.nekoit.xyz/Archivist )   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    - [Github ](https://www.github.com/Zenohate )