s3mgo

package
v0.0.0-...-ac9ea8b Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBName            = "swifty-s3"
	DBColS3Iams       = "S3Iams"
	DBColS3Stats      = "S3Stats"
	DBColS3StatsArch  = "S3StatsA"
	DBColS3Buckets    = "S3Buckets"
	DBColS3Objects    = "S3Objects"
	DBColS3Uploads    = "S3Uploads"
	DBColS3ObjectData = "S3ObjectData"
	DBColS3DataChunks = "S3DataChunks"
	DBColS3AccessKeys = "S3AccessKeys"
	DBColS3Websites   = "S3Websites"
)
View Source
const (
	Resourse_Any = "*"
)

Most permissive mode

View Source
const TimeStampMax = int64(0x7fffffffffffffff)

Variables

This section is empty.

Functions

func AccountUser

func AccountUser(namespace, user string) string

To distingush iam users as an index

func BCookie

func BCookie(namespace, bucket string) string

Bucket pool name and index in DB for lookup

Types

type AccessKey

type AccessKey struct {
	ObjID bson.ObjectId `bson:"_id,omitempty"`
	MTime int64         `bson:"mtime,omitempty"`
	State uint32        `bson:"state"`

	AccountObjID bson.ObjectId `bson:"account-id,omitempty"`
	IamObjID     bson.ObjectId `bson:"iam-id,omitempty"`

	CreationTimestamp   int64 `bson:"creation-timestamp,omitempty"`
	ExpirationTimestamp int64 `bson:"expiration-timestamp,omitempty"`

	AccessKeyID     string `bson:"access-key-id"`
	AccessKeySecret string `bson:"access-key-secret"`
}

func (*AccessKey) Expired

func (akey *AccessKey) Expired() bool

type Account

type Account struct {
	ObjID bson.ObjectId `bson:"_id,omitempty"`
	MTime int64         `bson:"mtime,omitempty"`
	State uint32        `bson:"state"`

	AwsID     string `bson:"aws-id,omitempty"`
	Namespace string `bson:"namespace,omitempty"`

	CreationTime string `bson:"creation-time,omitempty"`
	User         string `bson:"user,omitempty"`
	Email        string `bson:"email,omitempty"`
}

func (*Account) BCookie

func (account *Account) BCookie(bname string) string

func (*Account) IamUser

func (account *Account) IamUser(user string) string

func (*Account) NamespaceID

func (account *Account) NamespaceID() string

Bucket grouping by namespace in DB for lookup

type AcctLimits

type AcctLimits struct {
	CntBytes    int64 `bson:"cnt-bytes"`
	OutBytesTot int64 `bson:"out-bytes-tot"`
}

type AcctStats

type AcctStats struct {
	ObjID       bson.ObjectId `bson:"_id,omitempty"`
	NamespaceID string        `bson:"nsid,omitempty"`

	CntObjects  int64 `bson:"cnt-objects"`
	CntBytes    int64 `bson:"cnt-bytes"`
	OutBytes    int64 `bson:"out-bytes"`
	OutBytesWeb int64 `bson:"out-bytes-web"`

	OutBytesTotOff int64 `bson:"out-bytes-tot-off"`

	/* Ach stuff */
	/*
	 * Dirty -- it's the ID of the original stats object on which we
	 * need to update offsets for increasing counters. Set on archive
	 * at creation, and is cleaned once the offsets are update in
	 * the original stats. See scraper code for details.
	 */
	Dirty *bson.ObjectId `bson:"dirty,omitempty"`
	Till  *time.Time     `bson:"till,omitempty"`
	Lim   *AcctLimits    `bson:"limits,omitempty"`
}

type ActionBits

type ActionBits [2]uint64

func (ActionBits) ToMgo

func (v ActionBits) ToMgo() ActionBitsMgo

type ActionBitsMgo

type ActionBitsMgo [16]byte

func (ActionBitsMgo) ToSwy

func (v ActionBitsMgo) ToSwy() ActionBits

type Bucket

type Bucket struct {
	ObjID   bson.ObjectId `bson:"_id,omitempty"`
	BCookie string        `bson:"bcookie,omitempty"`

	MTime int64  `bson:"mtime,omitempty"`
	State uint32 `bson:"state"`

	NamespaceID  string `bson:"nsid,omitempty"`
	CreationTime string `bson:"creation-time,omitempty"`

	// Todo
	Versioning     bool          `bson:"versioning,omitempty"`
	TagSet         []Tag         `bson:"tags,omitempty"`
	Encrypt        BucketEncrypt `bson:"encrypt,omitempty"`
	Location       string        `bson:"location,omitempty"`
	Policy         string        `bson:"policy,omitempty"`
	Logging        bool          `bson:"logging,omitempty"`
	Lifecycle      string        `bson:"lifecycle,omitempty"`
	RequestPayment string        `bson:"request-payment,omitempty"`

	Ref         int64         `bson:"ref"`
	CntObjects  int64         `bson:"cnt-objects"`
	CntBytes    int64         `bson:"cnt-bytes"`
	Rover       int64         `bson:"rover"`
	Name        string        `bson:"name"`
	CannedAcl   string        `bson:"canned-acl"`
	BasicNotify *BucketNotify `bson:"notify,omitempty"`

	MaxObjects int64 `bson:"max-objects"`
	MaxBytes   int64 `bson:"max-bytes"`
}

func (*Bucket) OCookie

func (bucket *Bucket) OCookie(oname string, version int) string

Object key in backend and index in DB for lookup

func (*Bucket) UploadUID

func (bucket *Bucket) UploadUID(oname string) string

UploadID for DB lookup

type BucketEncrypt

type BucketEncrypt struct {
	Algo        string `bson:"algo"`
	MasterKeyID string `bson:"algo,omitempty"`
}

type BucketNotify

type BucketNotify struct {
	Queue  string `bson:"queue"`
	Put    uint32 `bson:"put"`
	Delete uint32 `bson:"delete"`
}

type DataChunk

type DataChunk struct {
	ObjID bson.ObjectId `bson:"_id,omitempty"`
	Bytes []byte        `bson:"bytes"`
}

type Iam

type Iam struct {
	ObjID bson.ObjectId `bson:"_id,omitempty"`
	MTime int64         `bson:"mtime,omitempty"`
	State uint32        `bson:"state"`

	AwsID        string        `bson:"aws-id,omitempty"`
	AccountObjID bson.ObjectId `bson:"account-id,omitempty"`

	Policy       Policy `bson:"policy,omitempty"`
	CreationTime string `bson:"creation-time,omitempty"`
	User         string `bson:"user,omitempty"`
}

type Object

type Object struct {
	ObjID   bson.ObjectId `bson:"_id,omitempty"`
	OCookie string        `bson:"ocookie"`

	MTime int64  `bson:"mtime,omitempty"`
	State uint32 `bson:"state"`

	BucketObjID bson.ObjectId `bson:"bucket-id,omitempty"`
	Version     int           `bson:"version"`
	Rover       int64         `bson:"rover"`
	Size        int64         `bson:"size"`
	ETag        string        `bson:"etag"`

	ObjectProps `bson:",inline"`
}

type ObjectPart

type ObjectPart struct {
	ObjID bson.ObjectId `bson:"_id,omitempty"`

	MTime int64  `bson:"mtime,omitempty"`
	State uint32 `bson:"state"`

	RefID        bson.ObjectId   `bson:"ref-id,omitempty"`
	BCookie      string          `bson:"bcookie,omitempty"`
	OCookie      string          `bson:"ocookie,omitempty"`
	CreationTime string          `bson:"creation-time,omitempty"`
	Size         int64           `bson:"size"`
	Part         uint            `bson:"part"`
	ETag         string          `bson:"etag"`
	Data         []byte          `bson:"data,omitempty"`
	Chunks       []bson.ObjectId `bson:"chunks"`
}

type ObjectProps

type ObjectProps struct {
	CreationTime string `bson:"creation-time,omitempty"`
	Acl          string `bson:"acl,omitempty"`
	Key          string `bson:"key"`

	// Todo
	Meta   []Tag  `bson:"meta,omitempty"`
	TagSet []Tag  `bson:"tags,omitempty"`
	Policy string `bson:"policy,omitempty"`
}

type Policy

type Policy struct {
	Effect   string        `bson:"effect,omitempty"`
	Action   ActionBitsMgo `bson:"action,omitempty"`
	Resource []string      `bson:"resource,omitempty"`
}

func (*Policy) Allowed

func (policy *Policy) Allowed(action int) bool

func (*Policy) Equal

func (policy *Policy) Equal(dst *Policy) bool

func (*Policy) InfoLong

func (policy *Policy) InfoLong() string

func (*Policy) MayAccess

func (policy *Policy) MayAccess(resource string) bool

type Tag

type Tag struct {
	Key   string `bson:"key"`
	Value string `bson:"value,omitempty"`
}

Jump to

Keyboard shortcuts

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