routing

package
v0.4.96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package routing includes utilities for routing and assignments. See https://serviceweaver.dev/docs.html#routing for more information on routing.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualSlices

func EqualSlices(replicas []string) *protos.Assignment

EqualSlices returns an assignment with slices of roughly equal size. Replicas are assigned to slices in a round robin fashion. The returned assignment has a version of 0.

func FormatAssignment

func FormatAssignment(a *protos.Assignment) string

FormatAssignment pretty formats the provided assignment.

Example
assignment := &protos.Assignment{
	Slices: []*protos.Assignment_Slice{
		{Start: 0x0, Replicas: []string{"a", "b"}},
		{Start: 0x3333333333333333, Replicas: []string{"a", "c"}},
		{Start: 0x6666666666666666, Replicas: []string{"b", "c"}},
		{Start: 0x9999999999999999, Replicas: []string{"a", "b", "c"}},
	},
	Version: 42,
}
fmt.Println(FormatAssignment(assignment))
Output:

Assignment Version 42
[0x0000000000000000, 0x3333333333333333): [a b]
[0x3333333333333333, 0x6666666666666666): [a c]
[0x6666666666666666, 0x9999999999999999): [b c]
[0x9999999999999999, 0xffffffffffffffff]: [a b c]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL