sociallab

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sociallab is SocialLab, a social network's API: a home feed built from the accounts a user follows, posts, likes, comments, follows, and notifications delivered live over a WebSocket. It is the reference app for the social pack.

Twenty celebrity accounts are followed by everyone, which is where a viral spike lands.

Planted bottlenecks (see README.md), each switched off by a fix flag:

  • timeline: the home feed is built on every read by gathering every post of every followed account and sorting them all (fix "timeline" keeps a per-user timeline filled as posts are written, and merges in only the newest celebrity posts when it is read).
  • likes: every like takes one global lock, checks for a repeat like by scanning the post's list of likers and writes the like row (2ms) before letting go, so likes run one at a time across the whole app and a viral post's likes slow down as they pile up (fix "likes" keeps likers in a set under the post's own lock and writes the row outside it).
  • notify: each notification is stored (2ms) and written to the recipient's open sockets inside the like, comment or follow request, under one notification lock, so a burst of likes queues up behind it and a celebrity's sockets slow every like down (fix "notify" hands notifications to a queue whose worker stores them and passes them to each socket's own writer).

Index

Constants

View Source
const (
	// Users is how many accounts SocialLab has (user0001 ... user5000).
	Users = 5000
	// Celebrities are user0001 ... user0020, followed by everyone.
	Celebrities = 20
	// Password is every account's password.
	Password = "sociallab-pass"
)

Variables

This section is empty.

Functions

func New

func New(cfg labkit.Config) http.Handler

New returns SocialLab's handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

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