shard

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package shard is a dynamic storage backend that synthesizes a shard declaration.

Index

Constants

View Source
const (
	ManifestType          = "management"
	DeclarationType       = "com.apple.management.properties"
	DeclarationIdentifier = "com.github.jessepeterson.kmfddm.storage.shard.v1"
)

Variables

This section is empty.

Functions

func FNV1Shard added in v0.7.0

func FNV1Shard(input string) string

FNV1Shard hashes input using FNV1 modulo 101.

Types

type Option added in v0.7.0

type Option func(*ShardStorage)

func WithShardFunc added in v0.7.0

func WithShardFunc(f ShardFunc) Option

WithShardFunc sets the shard function to f.

type ShardFunc added in v0.7.0

type ShardFunc func(string) string

ShardFunc computes a shard value. A string of a decimal value between 0 and 100 inclusive should be returned. I.e. "42".

type ShardStorage

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

ShardStorage is a dynamic storage backend that synthesizes a shard declaration. The declaration is a management properties declaration that sets the "shard" property to the shard number for the enrollment. This can then be used in activation predicates. The shard number is computed from the enrollment ID.

func NewShardStorage

func NewShardStorage(opts ...Option) *ShardStorage

NewShardStorage creates a new shard storage. By default the shard function is hashed using FNV1Shard. Use WithShardFunc to change it.

func (*ShardStorage) RetrieveDeclarationItems

func (s *ShardStorage) RetrieveDeclarationItems(_ context.Context, enrollmentID string) ([]*ddm.Declaration, error)

RetrieveDeclarationItems synthesizes a dynamic shard declaration. Used for injection into the declaration items and sync tokens.

func (*ShardStorage) RetrieveEnrollmentDeclarationJSON

func (s *ShardStorage) RetrieveEnrollmentDeclarationJSON(_ context.Context, declarationID, declarationType, enrollmentID string) ([]byte, error)

RetrieveEnrollmentDeclarationJSON synthesizes a dynamic shard declaration.

Jump to

Keyboard shortcuts

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