Using plumbing

Plumbing is a mechanism for passing messages between applications. It has a customizable set of rules (see plumb(6)) to process incoming messages and dispatch them to target applications.

The plumber(4) is the file server that performs the message processing and dispatch.

It is up to each application how it wishes to use this mechanism, but in the user-interface domain, the mechanism often allows the user to point to a file-name or URL and have the associated resource processed by an appropriate application.

EXAMPLES

In the rc shell window you can select or position the text cursor inside a piece of text and press button 2 and select "plumb" from the pop-up menu. Depending on what the text is, the plumber will perform different actions. For example:

The plumber can provide easy shortcuts for common functions. For example, given a script 'web' which takes an argument of a URL to open in a web browser, the plumbing rule:

	# RFC's from one of the nicer-looking repositories.
	type is text
	data matches 'RFC:([0-9]+)'
	plumb to web
	plumb start web http://rfc.sunsite.dk/rfc/rfc$1.html
will make RFC:2325 a link to some of the IETF's better work. A number of other potentially useful plumbing examples have been collected.

A NICE TRICK

Namespaces in Plan 9 are local. That is, if you're inside an application that has forked the namespace, you can't change the namespace visible to other applications. In particular, you can't mount a remote file server and then plumb it to another running application. Here's a neat trick that lets you do that.

	srvfs plumbspace /n
	plumber
	rfork n
	mount -b /srv/plumbspace /n

Put this in your /lib/profile (before rio is started) and /n is now an indirect part of the namespace that can be changed in all applications by the plumber. An extra rule in the plumber is all that's needed to make use of it:

type is text
data matches 'Local (.*)'
plumb to none
plumb start rc -c $1

For example, say I wished to mount a local kfs disk and edit a file in it. I can open a new shell window, type:

disk/kfs
plumb 'Local mount /srv/kfs /n/kfs'

and the files on the new disk will be visible to all applications on the machine, including, for example, an existing incarnation of Acme.

ADDITIONAL REFERENCES

Plumbing and Other Utilities - A paper on the design and implementation of the plumbing system.