當前位置: 首頁>>代碼示例>>Golang>>正文


Golang storage.Tx類代碼示例

本文整理匯總了Golang中github.com/chop-dbhi/origins/storage.Tx的典型用法代碼示例。如果您正苦於以下問題:Golang Tx類的具體用法?Golang Tx怎麽用?Golang Tx使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Tx類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetSegment

// GetSegment returns a segment from storage.
func GetSegment(e storage.Tx, domain string, id *uuid.UUID) (*Segment, error) {
	var (
		bytes []byte
		err   error
		key   string
	)

	key = fmt.Sprintf(segmentKey, id)

	if bytes, err = e.Get(domain, key); err != nil {
		return nil, err
	}

	if bytes == nil {
		return nil, nil
	}

	seg := Segment{
		UUID:   id,
		Domain: domain,
	}

	if err = unmarshalSegment(bytes, &seg); err != nil {
		return nil, err
	}

	return &seg, nil
}
開發者ID:l-k-,項目名稱:origins,代碼行數:29,代碼來源:methods.go

示例2: SetBlock

func SetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int, bytes []byte) (int, error) {
	var key string

	key = fmt.Sprintf(blockKey, id, idx)

	return len(bytes), e.Set(domain, key, bytes)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:7,代碼來源:methods.go

示例3: GetLog

func GetLog(e storage.Tx, domain, name string) (*Log, error) {
	var (
		bytes []byte
		err   error
		key   string
	)

	key = fmt.Sprintf(logKey, name)

	if bytes, err = e.Get(domain, key); err != nil {
		return nil, err
	}

	if bytes == nil {
		return nil, nil
	}

	log := Log{
		Domain: domain,
		Name:   name,
	}

	if err = unmarshalLog(bytes, &log); err != nil {
		return nil, err
	}

	return &log, nil
}
開發者ID:l-k-,項目名稱:origins,代碼行數:28,代碼來源:methods.go

示例4: GetBlock

// GetBlock returns a block from storage. The lookup requires the domain, ID of the segment
// the block is contained in, the index of the block in the segment, and the transaction
// that processed the segment.
func GetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) ([]byte, error) {
	var key string

	key = fmt.Sprintf(blockKey, id, idx)

	return e.Get(domain, key)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:10,代碼來源:methods.go

示例5: SetLog

func SetLog(e storage.Tx, domain string, log *Log) (int, error) {
	var (
		bytes []byte
		err   error
		key   string
	)

	if bytes, err = marshalLog(log); err != nil {
		return 0, err
	}

	key = fmt.Sprintf(logKey, log.Name)

	return len(bytes), e.Set(domain, key, bytes)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:15,代碼來源:methods.go

示例6: SetSegment

func SetSegment(e storage.Tx, domain string, segment *Segment) (int, error) {
	var (
		bytes []byte
		err   error
		key   string
	)

	if bytes, err = marshalSegment(segment); err != nil {
		return 0, err
	}

	key = fmt.Sprintf(segmentKey, segment.UUID)

	return len(bytes), e.Set(domain, key, bytes)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:15,代碼來源:methods.go

示例7: DeleteLog

func DeleteLog(e storage.Tx, domain string, name string) error {
	key := fmt.Sprintf(logKey, name)

	return e.Delete(domain, key)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:5,代碼來源:methods.go

示例8: DeleteBlock

func DeleteBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) error {
	key := fmt.Sprintf(blockKey, id, idx)

	return e.Delete(domain, key)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:5,代碼來源:methods.go

示例9: DeleteSegment

func DeleteSegment(e storage.Tx, domain string, id *uuid.UUID) error {
	key := fmt.Sprintf(segmentKey, id)

	return e.Delete(domain, key)
}
開發者ID:l-k-,項目名稱:origins,代碼行數:5,代碼來源:methods.go

示例10: txid

// txid increments a global transaction ID.
func txid(tx storage.Tx) (uint64, error) {
	return tx.Incr("origins", "tx")
}
開發者ID:l-k-,項目名稱:origins,代碼行數:4,代碼來源:transact.go


注:本文中的github.com/chop-dbhi/origins/storage.Tx類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。