Documentation ¶
Overview ¶
The chkpt package implements a checkpoint file manager. The checkpoint scheme is based on a two tumbler (a and b) system where the b tumber cyles with each call, and the a tumber cycles once with each roll-over of b. If the roll point of b is 24 and the roll point of a is three, checkpoint files are created in this order:
a1, b1, b2, b3... b24, a2, b1... b24, a2...
If the using programme is creating a checkpoint every hour, then an 'a' file is created once per day with a coverage of three days; at the end of the third cycle there will exist a1 (2 days old), a2 (one day old) and a3 new, along with 24 'b' files.
As the checkpoint is written, the mdd5sum is computed and if desired upon close the value is added to the name such that final names have the form:
<path>_Xnn-<md5>.ckpt
This is enabled by invoking the Add_md5() function after the checkpoint object is created.
The file <path>.ckpt (no tumbler) is used to record the tumbler values such that the next time the programme is started it will create the next file in a continued sequence rather than resetting or requiring the user programme to manage the tumbler data.
chkpt implements the io.Writer interface such that it is possible to use the pointer to the object in an fmt.Fprintf() call:
c = Mk_chkpt( "/usr2/ckpts/agama", 5, 25 ) c.Create() fmt.Fprintf( c, "%s\n", data ) c.Close()
The method Write_string( string ) can also be used to write to an open checkpoint file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chkpt ¶
type Chkpt struct {
// contains filtered or unexported fields
}
Defines a checkpoint environment.
func Mk_chkpt ¶
Mk_chkpt creates a checkpointing environment. Path is any leading directory path, with a basename (prefix) mask (e.g. /usr2/backups/foo). The tumbler information is added to path in the form of either a_xxxx or b_xxxx where xxx is the tumbler number.
func (*Chkpt) Add_md5 ¶
func (c *Chkpt) Add_md5()
Sets the flag that will cause the final file name to include the MD5 value computed for the file. Adding the md5 breaks the 'overlay' nature of the tumbler system.
func (*Chkpt) Close ¶
Closes the open checkpoint file. The final file is renamed with the md5sum (if no write errors). The final filename and any error status are reported to the caller. Success is reported (err == nil) only when no write errors and a successful close/rename.
func (*Chkpt) Create ¶
The create method caues a new checkpoint file to be created and opened. Once opened, thw Write or Write_string methods can be called to write to the the file. The Close method should be invoked when all writing has occurred.