container

package
v1.25.1-0...-2fdc35d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AttributeName is an attribute key that is commonly used to denote
	// human-friendly name.
	AttributeName = "Name"

	// AttributeTimestamp is an attribute key that is commonly used to denote
	// user-defined local time of container creation in Unix Timestamp format.
	AttributeTimestamp = "Timestamp"
)

Variables

View Source
var NewID = cid.New

NewID creates and initializes blank ID.

Works similar to NewIDFromV2(new(ContainerID)).

Deprecated: use cid.New instead.

View Source
var NewIDFromV2 = cid.NewFromV2

NewIDFromV2 wraps v2 ContainerID message to ID.

Deprecated: use cid.NewFromV2 instead.

Functions

func CalculateID

func CalculateID(c *Container) *cid.ID

CalculateID calculates container identifier based on its structure.

Types

type Attribute

type Attribute container.Attribute

func NewAttribute

func NewAttribute() *Attribute

NewAttribute creates and initializes blank Attribute.

Defaults:

  • key: "";
  • value: "".

func NewAttributeFromV2

func NewAttributeFromV2(v *container.Attribute) *Attribute

NewAttributeFromV2 wraps protocol dependent version of Attribute message.

Nil container.Attribute converts to nil.

func (*Attribute) Key

func (a *Attribute) Key() string

func (*Attribute) SetKey

func (a *Attribute) SetKey(v string)

func (*Attribute) SetValue

func (a *Attribute) SetValue(v string)

func (*Attribute) ToV2

func (a *Attribute) ToV2() *container.Attribute

ToV2 converts Attribute to v2 Attribute message.

Nil Attribute converts to nil.

func (*Attribute) Value

func (a *Attribute) Value() string

type Attributes

type Attributes []*Attribute

func NewAttributesFromV2

func NewAttributesFromV2(v []*container.Attribute) Attributes

func (Attributes) ToV2

func (a Attributes) ToV2() []*container.Attribute

type Container

type Container struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...NewOption) *Container

New creates, initializes and returns blank Container instance.

Defaults:

  • token: nil;
  • sig: nil;
  • basicACL: acl.PrivateBasicRule;
  • version: nil;
  • nonce: random UUID;
  • attr: nil;
  • policy: nil;
  • ownerID: nil.

func NewContainerFromV2

func NewContainerFromV2(c *container.Container) *Container

NewVerifiedFromV2 constructs Container from NeoFS API V2 Container message.

Does not perform if message meets NeoFS API V2 specification. To do this use NewVerifiedFromV2 constructor.

func (*Container) Attributes

func (c *Container) Attributes() Attributes

func (*Container) BasicACL

func (c *Container) BasicACL() uint32

func (*Container) Marshal

func (c *Container) Marshal(b ...[]byte) ([]byte, error)

Marshal marshals Container into a protobuf binary form.

Buffer is allocated when the argument is empty. Otherwise, the first buffer is used.

func (*Container) MarshalJSON

func (c *Container) MarshalJSON() ([]byte, error)

MarshalJSON encodes Container to protobuf JSON format.

func (*Container) Nonce deprecated

func (c *Container) Nonce() []byte

Nonce returns container nonce in a binary format.

Returns nil if container nonce is not a valid UUID.

Deprecated: use NonceUUID instead.

func (*Container) NonceUUID

func (c *Container) NonceUUID() (uuid.UUID, error)

Returns container nonce in UUID format.

Returns error if container nonce is not a valid UUID.

func (*Container) OwnerID

func (c *Container) OwnerID() *owner.ID

func (*Container) PlacementPolicy

func (c *Container) PlacementPolicy() *netmap.PlacementPolicy

func (Container) SessionToken

func (c Container) SessionToken() *session.Token

SessionToken returns token of the session within which container was created.

func (*Container) SetAttributes

func (c *Container) SetAttributes(v Attributes)

func (*Container) SetBasicACL

func (c *Container) SetBasicACL(v uint32)

func (*Container) SetNonce deprecated

func (c *Container) SetNonce(v []byte)

SetNonce sets container nonce in a binary format.

If slice length is less than UUID size, than value is padded with a sequence of zeros. If slice length is more than UUID size, than value is cut.

Deprecated: use SetNonceUUID instead.

func (*Container) SetNonceUUID

func (c *Container) SetNonceUUID(v uuid.UUID)

SetNonceUUID sets container nonce as UUID.

func (*Container) SetOwnerID

func (c *Container) SetOwnerID(v *owner.ID)

func (*Container) SetPlacementPolicy

func (c *Container) SetPlacementPolicy(v *netmap.PlacementPolicy)

func (*Container) SetSessionToken

func (c *Container) SetSessionToken(t *session.Token)

SetSessionToken sets token of the session within which container was created.

func (*Container) SetSignature

func (c *Container) SetSignature(sig *pkg.Signature)

SetSignature sets signature of the marshaled container.

func (*Container) SetVersion

func (c *Container) SetVersion(v *pkg.Version)

func (Container) Signature

func (c Container) Signature() *pkg.Signature

Signature returns signature of the marshaled container.

func (*Container) ToV2

func (c *Container) ToV2() *container.Container

ToV2 returns the v2 Container message.

Nil Container converts to nil.

func (*Container) Unmarshal

func (c *Container) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of Container.

func (*Container) UnmarshalJSON

func (c *Container) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Container from protobuf JSON format.

func (*Container) Version

func (c *Container) Version() *pkg.Version

type ID deprecated

type ID = cid.ID

ID represents v2-compatible container identifier.

Deprecated: use cid.ID instead.

type NewOption

type NewOption interface {
	// contains filtered or unexported methods
}

func WithAttribute

func WithAttribute(key, value string) NewOption

func WithCustomBasicACL

func WithCustomBasicACL(acl uint32) NewOption

func WithNEO3Wallet

func WithNEO3Wallet(w *owner.NEO3Wallet) NewOption

func WithNonce

func WithNonce(nonce uuid.UUID) NewOption

func WithOwnerID

func WithOwnerID(id *owner.ID) NewOption

func WithPolicy

func WithPolicy(policy *netmap.PlacementPolicy) NewOption

func WithPublicBasicACL

func WithPublicBasicACL() NewOption

func WithReadOnlyBasicACL

func WithReadOnlyBasicACL() NewOption

type UsedSpaceAnnouncement

type UsedSpaceAnnouncement container.UsedSpaceAnnouncement

UsedSpaceAnnouncement is an announcement message used by storage nodes to estimate actual container sizes.

func NewAnnouncement

func NewAnnouncement() *UsedSpaceAnnouncement

NewAnnouncement initialize empty UsedSpaceAnnouncement message.

Defaults:

  • epoch: 0;
  • usedSpace: 0;
  • cid: nil.

func NewAnnouncementFromV2

func NewAnnouncementFromV2(v *container.UsedSpaceAnnouncement) *UsedSpaceAnnouncement

NewAnnouncementFromV2 wraps protocol dependent version of UsedSpaceAnnouncement message.

Nil container.UsedSpaceAnnouncement converts to nil.

func (*UsedSpaceAnnouncement) ContainerID

func (a *UsedSpaceAnnouncement) ContainerID() *cid.ID

ContainerID of the announcement.

func (*UsedSpaceAnnouncement) Epoch

func (a *UsedSpaceAnnouncement) Epoch() uint64

Epoch of the announcement.

func (*UsedSpaceAnnouncement) Marshal

func (a *UsedSpaceAnnouncement) Marshal(b ...[]byte) ([]byte, error)

Marshal marshals UsedSpaceAnnouncement into a protobuf binary form.

Buffer is allocated when the argument is empty. Otherwise, the first buffer is used.

func (*UsedSpaceAnnouncement) SetContainerID

func (a *UsedSpaceAnnouncement) SetContainerID(cid *cid.ID)

SetContainerID sets announcement container value.

func (*UsedSpaceAnnouncement) SetEpoch

func (a *UsedSpaceAnnouncement) SetEpoch(epoch uint64)

SetEpoch sets announcement epoch value.

func (*UsedSpaceAnnouncement) SetUsedSpace

func (a *UsedSpaceAnnouncement) SetUsedSpace(value uint64)

SetUsedSpace sets used space value by specified container.

func (*UsedSpaceAnnouncement) ToV2

ToV2 returns protocol dependent version of UsedSpaceAnnouncement message.

Nil UsedSpaceAnnouncement converts to nil.

func (*UsedSpaceAnnouncement) Unmarshal

func (a *UsedSpaceAnnouncement) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of UsedSpaceAnnouncement.

func (*UsedSpaceAnnouncement) UsedSpace

func (a *UsedSpaceAnnouncement) UsedSpace() uint64

UsedSpace in container.

Directories

Path Synopsis
id

Jump to

Keyboard shortcuts

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