k3confloader

pykit3 is is a collection of toolkit in python3.

Documentation for the Code

k3confloader loads conf for other pykit3 modules. k3confloader tries to load a python file k3conf.py and expected it contains configuration.

Usage:

Setup config:

echo 'uid=3' > k3conf.py

Then:

import k3confloader
print(k3confloader.conf.uid)
3

Classes

class k3confloader.ConfGetter

This is a lazy loader that tries to import k3conf.py when configure attributes are read.

If an attribute is not set in k3conf.py, a default value is used.

uid

the user id to assign when creating file/dir. Default: None.

Type

int

gid

the group id to assign when creating file/dir. Default: None.

Type

int

log_dir

the log dir. Default: ‘/tmp’.

Type

str

cat_stat_dir

the dir to store offset of an unfinished cat operation. Default: None.

Type

str

zk_acl

default zookeeper acl when creating a node in form of: ((‘xp’, ‘123’, ‘cdrwa’), (‘foo’, ‘bar’, ‘rw’)). Default: None.

Type

tuples

zk_auth

zookeeper auth info when connecting zk in form of: (‘digest’, ‘xp’, ‘123’). Default: None.

Type

tuple

iostat_stat_path

a path to file to store incremental stat collection. Default: ‘/tmp/pykit-iostat’.

Type

str

zk_hosts

default zookeeper host to connect, seperated by comma. Default: ‘127.0.0.1:21811’.

Type

str

zk_lock_dir

default zk-dir path to impl a distributed locking. Default: ‘lock/’.

Type

str

zk_node_id

a node id generated from MAC. Default: ‘%012x’ % uuid.getnode().

Type

str

zk_record_dir

default zk-dir to store records of a distributed transaction. Default: ‘record/’.

Type

str

zk_tx_dir

default zk-dir to store tx info of a distributed transaction. Default: ‘tx/’.

Type

str

zk_seq_dir

default zk-dir for generating mono incremental seq number. Default: ‘seq/’.

Type

str

zk_tx_timeout

default timeout in second for a zk based distributed transaction. Default: 365 * 24 * 3600.

Type

str

rp_cli_nwr

default NWR(n, write, read) config of majority read/write for redis proxy. Default: (3, 2, 2).

Type

tuple

rp_cli_ak_sk

default access key and secret key to auth access to redis proxy. Default: (‘access_key’, ‘secret_key’).

Type

tuple

ec_block_port

default base tcp-port for EC block server. Default: 6000. Deprecated.

Type

int

inner_ip_patterns

default inner-network address regexp. Compatible with both python regexp and lua pattern. Default: [‘^172[.]1[6-9].*’, ‘^172[.]2[0-9].*’, ‘^172[.]3[0-1].*’, ‘^10[.].*’, ‘^192[.]168[.].*’].

Type

str

Functions

Indices and tables