github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/storage-object.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  // StorageObjects is the interface that show how an object directory work.
     6  // Object owner is one app so it must handle concurrent protection internally.
     7  // Strongly think fundementally due to all data in computer must store as k/v in storages finally even files or rows.
     8  // - mediaTypeID equivalent to table-name(RDB), namespace(Key-Value) or BucketID(AWS S3), but mediaTypeID has more meaning and has fixed size.
     9  // - 16 byte id choose to defeat https://en.wikipedia.org/wiki/Birthday_problem due to we suggest use hash(sha3-256 to 128bit) of any data as object key.
    10  // If need encryption, Implement requirements at block storage level.
    11  type StorageObjects interface {
    12  	MediatypeNumbers() (num uint64, err Error)
    13  	ListMediatypeIDs(offset, limit uint64) (ids []uint64, err Error)
    14  	ObjectNumbers(mediaTypeID uint64) (num uint64, err Error)
    15  	ListObjects(mediaTypeID uint64, offset, limit uint64) (ids [][16]byte, err Error)
    16  
    17  	Lock(mediaTypeID uint64, id [16]byte) (err Error)
    18  	Unlock(mediaTypeID uint64, id [16]byte) (err Error)
    19  
    20  	Length(mediaTypeID uint64, id [16]byte) (ln int, err Error)
    21  	Get(mediaTypeID uint64, id [16]byte) (object []byte, err Error)
    22  	Read(mediaTypeID uint64, id [16]byte, offset, limit uint64) (data []byte, err Error)
    23  	Save(mediaTypeID uint64, id [16]byte, object []byte) (err Error)
    24  	Write(mediaTypeID uint64, id [16]byte, offset uint64, data []byte) (err Error)
    25  
    26  	Append(mediaTypeID uint64, id [16]byte, data []byte) (err Error)
    27  	Prepend(mediaTypeID uint64, id [16]byte, data []byte) (err Error)
    28  	Extend(mediaTypeID uint64, id [16]byte, length uint64) (err Error)
    29  
    30  	// make invisible just by remove from primary index
    31  	Delete(mediaTypeID uint64, id [16]byte) (err Error)
    32  	// make invisible by remove from primary index & write zero data to object location
    33  	Erase(mediaTypeID uint64, id [16]byte) (err Error)
    34  
    35  	// Multiple changes can be made in one atomic batch
    36  	// Batch()
    37  }