Documentation
¶
Index ¶
- Variables
- func EachClusterServerArtifact[T any](r *Reader, artifactTag *Tag, ...) (int, error)
- func ForEachTaggedArtifact[T any](r *Reader, tags []*Tag, cb func(*T) error) error
- type AuditMetadata
- type Reader
- func (r *Reader) AccountNames() []string
- func (r *Reader) AccountStreamNames(accountName string) []string
- func (r *Reader) Close() error
- func (r *Reader) ClusterNames() []string
- func (r *Reader) ClusterServerNames(clusterName string) []string
- func (r *Reader) EachClusterServerAccountz(cb func(clusterTag *Tag, serverTag *Tag, err error, ...) error) (int, error)
- func (r *Reader) EachClusterServerHealthz(cb func(clusterTag *Tag, serverTag *Tag, err error, ...) error) (int, error)
- func (r *Reader) EachClusterServerJsz(...) (int, error)
- func (r *Reader) EachClusterServerLeafz(...) (int, error)
- func (r *Reader) EachClusterServerVarz(...) (int, error)
- func (r *Reader) Load(v any, queryTags ...*Tag) error
- func (r *Reader) StreamServerNames(accountName, streamName string) []string
- type Tag
- func TagAccount(accountName string) *Tag
- func TagAccountConnections() *Tag
- func TagAccountInfo() *Tag
- func TagAccountJetStream() *Tag
- func TagAccountLeafs() *Tag
- func TagAccountSubs() *Tag
- func TagArtifactType(artifactType string) *Tag
- func TagCluster(clusterName string) *Tag
- func TagNoCluster() *Tag
- func TagProfileName(profileType string) *Tag
- func TagServer(serverName string) *Tag
- func TagServerAccounts() *Tag
- func TagServerConnections() *Tag
- func TagServerGateways() *Tag
- func TagServerHealth() *Tag
- func TagServerJetStream() *Tag
- func TagServerLeafs() *Tag
- func TagServerProfile() *Tag
- func TagServerRoutes() *Tag
- func TagServerSubs() *Tag
- func TagServerVars() *Tag
- func TagSpecial(special string) *Tag
- func TagStream(streamName string) *Tag
- func TagStreamInfo() *Tag
- type TagLabel
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrMultipleMatches = fmt.Errorf("multiple files matched the given query")
ErrMultipleMatches is returned if multiple artifact matched the input combination of tags
var ErrNoMatches = fmt.Errorf("no file matched the given query")
ErrNoMatches is returned if no artifact matched the input combination of tags
Functions ¶
func EachClusterServerArtifact ¶ added in v0.2.3
func EachClusterServerArtifact[T any](r *Reader, artifactTag *Tag, cb func(clusterTag *Tag, serverTag *Tag, err error, artifact *T) error) (int, error)
EachClusterServerArtifact iterates over all paged JSON artifact files in the archive by looping through every cluster and its servers. For each cluster, server pair, it constructs a tag slice consisting of the cluster tag, server tag, and the provided artifact tag, and then calls ForEachTaggedArtifact to load all artifacts of type T associated with that combination.
The matching artifact files are obtained by intersecting the tag-specific file lists from the Reader’s inverted index, and then filtered and sorted according to the paged artifact naming convention. For each decoded artifact, the provided callback function is called with the cluster tag, the server tag, and the loaded artifact (or an error if no matching artifact was found).
The function returns the total count of processed artifacts and any error encountered during iteration.
func ForEachTaggedArtifact ¶ added in v0.2.3
ForEachTaggedArtifact iterates over all paged JSON artifact files in the archive that match the given set of tags and calls the provided callback function for each decoded artifact.
The function uses the Reader’s inverted index to collect the file names associated with each tag, performs an intersection of these sets to determine the files that match all the given tags, and then filters these to include only those files that match the paged artifact naming convention.
The matching files are sorted by name, opened, and decoded from JSON into an object of type T. For each decoded artifact, the callback function cb is called. If the callback returns an error we iterating and the error is returned.
If no files match the provided tags it returns ErrNoMatches. It also returns any errors encountered during file opening or JSON decoding.
Types ¶
type AuditMetadata ¶
type AuditMetadata struct {
Timestamp time.Time `json:"capture_timestamp"`
ConnectedServerName string `json:"connected_server_name"`
ConnectedServerVersion string `json:"connected_server_version"`
ConnectURL string `json:"connect_url"`
UserName string `json:"user_name"`
CLIVersion string `json:"cli_version"`
}
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader encapsulates a reader for the actual underlying archive, and also provides indices for faster and more convenient iteration and querying of the archive content
func NewReader ¶
NewReader creates a new reader for the file at the given archivePath. Reader expect the file to comply to format and content created by a Writer in this same package. During creation, Reader creates in-memory indices to speed up subsequent queries.
func (*Reader) AccountNames ¶
AccountNames list the unique names of accounts found in the archive The list of names is sorted alphabetically
func (*Reader) AccountStreamNames ¶
AccountStreamNames list the unique stream names found in the archive for the given account The list of names is sorted alphabetically
func (*Reader) ClusterNames ¶
ClusterNames list the unique names of clusters found in the archive The list of names is sorted alphabetically
func (*Reader) ClusterServerNames ¶
ClusterServerNames list the unique server names found in the archive for the given cluster The list of names is sorted alphabetically
func (*Reader) EachClusterServerAccountz ¶
func (r *Reader) EachClusterServerAccountz(cb func(clusterTag *Tag, serverTag *Tag, err error, az *server.ServerAPIAccountzResponse) error) (int, error)
EachClusterServerAccountz iterates over all servers ordered by cluster and calls the callback function with the loaded Accountz response
The callback function will receive any error encountered during loading the server varz file and should check that and handle it If the callback returns an error iteration is stopped and that error is returned
Errors returned match those documented in Load() otherwise any other error that are encountered
func (*Reader) EachClusterServerHealthz ¶
func (r *Reader) EachClusterServerHealthz(cb func(clusterTag *Tag, serverTag *Tag, err error, hz *server.ServerAPIHealthzResponse) error) (int, error)
EachClusterServerHealthz iterates over all servers ordered by cluster and calls the callback function with the loaded Healthz response
The callback function will receive any error encountered during loading the server varz file and should check that and handle it If the callback returns an error iteration is stopped and that error is returned
Errors returned match those documented in Load() otherwise any other error that are encountered
func (*Reader) EachClusterServerJsz ¶
func (r *Reader) EachClusterServerJsz(cb func(clusterTag *Tag, serverTag *Tag, err error, jsz *server.ServerAPIJszResponse) error) (int, error)
EachClusterServerJsz iterates over all servers ordered by cluster and calls the callback function with the loaded Jsz response
The callback function will receive any error encountered during loading the server varz file and should check that and handle it If the callback returns an error iteration is stopped and that error is returned
Errors returned match those documented in Load() otherwise any other error that are encountered
func (*Reader) EachClusterServerLeafz ¶
func (r *Reader) EachClusterServerLeafz(cb func(clusterTag *Tag, serverTag *Tag, err error, lz *server.ServerAPILeafzResponse) error) (int, error)
EachClusterServerLeafz iterates over all servers ordered by cluster and calls the callback function with the loaded Leafz response
The callback function will receive any error encountered during loading the server varz file and should check that and handle it If the callback returns an error iteration is stopped and that error is returned
Errors returned match those documented in Load() otherwise any other error that are encountered
func (*Reader) EachClusterServerVarz ¶
func (r *Reader) EachClusterServerVarz(cb func(clusterTag *Tag, serverTag *Tag, err error, vz *server.ServerAPIVarzResponse) error) (int, error)
EachClusterServerVarz iterates over all servers ordered by cluster and calls the callback function with the loaded Varz response
The callback function will receive any error encountered during loading the server varz file and should check that and handle it If the callback returns an error iteration is stopped and that error is returned
Errors returned match those documented in Load() otherwise any other error that are encountered
func (*Reader) Load ¶
Load queries the indices for a single artifact matching the given input tags. If a single artifact is found, then it is deserialized into v If multiple artifact or no artifacts match the input tag, then ErrMultipleMatches and ErrNoMatches are returned respectively
func (*Reader) StreamServerNames ¶
StreamServerNames list the unique server names found in the archive for the given stream in the given account The list of names is sorted alphabetically
type Tag ¶
func TagAccount ¶
func TagAccountConnections ¶
func TagAccountConnections() *Tag
func TagAccountInfo ¶
func TagAccountInfo() *Tag
func TagAccountJetStream ¶
func TagAccountJetStream() *Tag
func TagAccountLeafs ¶
func TagAccountLeafs() *Tag
func TagAccountSubs ¶
func TagAccountSubs() *Tag
func TagArtifactType ¶
func TagCluster ¶
func TagNoCluster ¶
func TagNoCluster() *Tag
func TagProfileName ¶
func TagServerAccounts ¶
func TagServerAccounts() *Tag
func TagServerConnections ¶
func TagServerConnections() *Tag
func TagServerGateways ¶
func TagServerGateways() *Tag
func TagServerHealth ¶
func TagServerHealth() *Tag
func TagServerJetStream ¶
func TagServerJetStream() *Tag
func TagServerLeafs ¶
func TagServerLeafs() *Tag
func TagServerProfile ¶
func TagServerProfile() *Tag
func TagServerRoutes ¶
func TagServerRoutes() *Tag
func TagServerSubs ¶
func TagServerSubs() *Tag
func TagServerVars ¶
func TagServerVars() *Tag
func TagSpecial ¶
func TagStreamInfo ¶
func TagStreamInfo() *Tag
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer encapsulates a zip writer for the underlying archive file, but also tracks metadata used by the Reader to construct indices
func NewWriter ¶
NewWriter creates a new writer for the file at the given archivePath. Writer creates a ZIP file whose content has additional structure and metadata. If archivePath is an existing file, it will be overwritten.
func (*Writer) Add ¶
Add serializes the given artifact to JSON and adds it to the archive, it creates a file name based on the provided tags and ensures uniqueness. The artifact is also added to the manifest for indexing, enabling tag-based querying in via Reader
func (*Writer) AddRaw ¶
AddRaw adds the given artifact to the archive similarly to Add. The artifact is assumed to be already serialized and is copied as-is byte for byte. If the artifact is tagged as "special", it will be written as a single non-paged file.