-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applies spec change open-telemetry/opamp-spec#77
- Loading branch information
1 parent
b0398a1
commit 1882ca8
Showing
10 changed files
with
927 additions
and
1,256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package types | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
// PackagesSyncer can be used by the agent to initiate syncing a package from the server. | ||
// The PackagesSyncer instance knows the right context: the particular OpAMPClient and | ||
// the particular PackageAvailable message the OnPackageAvailable callback was called for. | ||
type PackagesSyncer interface { | ||
// Sync the available package from the server to the agent. | ||
// The agent must supply an PackagesStateProvider to let the Sync function | ||
// know what is available locally, what data needs to be sync and how the | ||
// data can be stored locally. | ||
Sync(ctx context.Context, localState PackagesStateProvider) error | ||
} | ||
|
||
type PackagesStateProvider interface { | ||
AllPackagesHash() ([]byte, error) | ||
|
||
// Packages returns the names of all packages that exist in the agent's local storage. | ||
Packages() ([]string, error) | ||
|
||
// PackageHash returns the hash of a local package. packageName is one of the names | ||
// that were returned by Packages(). | ||
PackageHash(packageName string) ([]byte, error) | ||
|
||
// CreatePackage creates the package locally. If the package existed must return an error. | ||
// If the package did not exist its hash should be set to nil. | ||
CreatePackage(packageName string) error | ||
|
||
// FileContentHash returns the content hash of the package file that exists locally. | ||
FileContentHash(packageName string) ([]byte, error) | ||
|
||
// UpdateContent must create or update the package content file. The entire content | ||
// of the file must be replaced by the data. The data must be read until | ||
// it returns an EOF. If reading from data fails UpdateContent must abort and return | ||
// an error. | ||
// Content hash must be updated if the data is updated without failure. | ||
// The function must cancel and return an error if the context is cancelled. | ||
UpdateContent(ctx context.Context, packageName string, data io.Reader, contentHash []byte) error | ||
|
||
// SetPackageHash must remember the hash for the specified package. Must be returned | ||
// later when PackageHash is called. SetPackageHash is called after all UpsertFile | ||
// and DeleteFile calls complete successfully. | ||
SetPackageHash(packageName string, hash []byte) error | ||
|
||
// DeletePackage deletes the package from the agent's local storage. | ||
DeletePackage(packageName string) error | ||
|
||
// SetAllPackagesHash must remember the AllPackagesHash. Must be returned | ||
// later when AllPackagesHash is called. SetAllPackagesHash is called after all | ||
// package updates complete successfully. | ||
SetAllPackagesHash(hash []byte) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.