Code Monkey home page Code Monkey logo

robin's Introduction

robin

Golang Weighted Round Robin implementation

The package implements the basic weighted round-robin balancing algorithm, it's go-routine safe and designed for concurrent use. See details in Wikipedia.

Classical WRR

In classical WRR the scheduler cycles over the queues. When a queue q-i is selected, the scheduler will send packets, up to the emission of w-i packet or the end of queue.

Constant and variables: 
    const N             // Nb of queues 
    const weight[1..N]  // weight of each queue
    queues[1..N]        // queues
    i                   // queue index
    c                   // packet counter
    
Instructions:
while true do 
    for i in 1 .. N do
        c := 0
        while (not queue[i].empty) and (c<weight[i]) do
            send(queue[i].head())
            queue[i].dequeue()
            c:= c+1
package main

import "fmt"

func main() {
	wrr := &WRR[string]{}
  wrr.Add("Beer", 5)
  wrr.Add("Vodka", 3)
  wrr.Add("Vine", 1)

	for i := 0; i < 10; i++ {
		fmt.Printf("%s ", wrr.Next())
	}
}

In future, the package will also provide Interleaved WRR algorithm implementation.

robin's People

Contributors

iserganov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.