-
Notifications
You must be signed in to change notification settings - Fork 8
Load dictionary from Hermes to Grafana plugin #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kevinthegreat1
wants to merge
54
commits into
main
Choose a base branch
from
grafana-plugin-dictionary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
cc64e8c
Prepare for Verification
YKawesome ad3efb6
Fix documentation and metadata
kevinthegreat1 00d01a1
Add init db if not exists
YKawesome c5c3a37
Remove provisioning
YKawesome 0201f01
ci: fix grafana plugin release workflow
YKawesome 4647ac2
Update release workflow to mirror grafana build-plugin
kevinthegreat1 83cb9c3
Fix minor issues in CI
YKawesome f95340c
Merge branch '81-deploy-plugin-figure-out-communityprivate-signing' o…
kevinthegreat1 315efec
Fix mage build command
kevinthegreat1 eacc8bf
Prevent triggering other CI on grafana-only changes
YKawesome 3ea5661
Fix CI linting errors
YKawesome ef89ee6
Fix working-directory
YKawesome 3de18af
Add empty install.sh
YKawesome 7731de9
Update README.md
kevinthegreat1 f47567c
Add doc to grafana release workflow
kevinthegreat1 18d6905
Add install script and docs
YKawesome 6d33935
Allow loading unsigned hermes datasource
kevinthegreat1 acdaf27
Update docs with installation options
YKawesome e2c4a66
Fix install script for alpine
YKawesome b2ab848
Update docker compose to install plugin
kevinthegreat1 06f6ce6
Update docs
kevinthegreat1 7ffc360
Merge branch 'main' into 81-deploy-plugin-figure-out-communityprivate…
YKawesome 2b57085
Cause Docker exit on failed hermes installation
YKawesome 7d74d0e
Merge branch '81-deploy-plugin-figure-out-communityprivate-signing' o…
YKawesome 8552210
Change default docker compose to timescale stack
kevinthegreat1 cf748a3
Fix provisioned datasource
kevinthegreat1 8453d38
Fix rebase
kevinthegreat1 ed740b2
Fix docs link to docker compose
kevinthegreat1 2982906
Update Release CI
YKawesome 3cedb3c
Merge branch '81-deploy-plugin-figure-out-communityprivate-signing' o…
YKawesome 6c8de9d
Update development readme and docs
kevinthegreat1 be938d9
Merge branch '81-deploy-plugin-figure-out-communityprivate-signing' o…
kevinthegreat1 3edbdc2
Rename directory from nasa-hermes-datasource to grafana-datasource-pl…
kevinthegreat1 e60ae87
Re-separate release workflows
kevinthegreat1 75f8cbd
Update grafana release
kevinthegreat1 b15c214
Fix grafana release
kevinthegreat1 ec9cb58
Change build vscode action name back
kevinthegreat1 0345c69
Pin Version + Update Install Script
YKawesome f4616d0
Update db and grafana docs extensively
kevinthegreat1 4d4dfa8
Merge branch '81-deploy-plugin-figure-out-communityprivate-signing' o…
kevinthegreat1 888cf1c
Tweak grafana docs
kevinthegreat1 5edb049
Fix logs docker container name
kevinthegreat1 c7504b6
Fix data field name and fix merge
kevinthegreat1 d0b880f
Update and clean up grafana plugin docs
kevinthegreat1 7fb4f50
Fix backend tests
kevinthegreat1 96c4ddd
Load dictionary from Hermes to Grafana plugin
kevinthegreat1 32168be
Merge branch 'main' into grafana-plugin-dictionary
kevinthegreat1 da136ca
Go mod tidy
kevinthegreat1 5eecf13
Merge branch 'main' into grafana-plugin-dictionary
kevinthegreat1 aa1e795
Add channel metadata as description
kevinthegreat1 4679d11
Parse metadata json in frontend
kevinthegreat1 538c0a5
Merge branch 'main' into grafana-plugin-dictionary
kevinthegreat1 be59237
Fix e2e test
kevinthegreat1 3c83769
Merge branch 'main' into grafana-plugin-dictionary
kevinthegreat1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,99 @@ | ||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync" | ||
| "time" | ||
|
|
||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/credentials/insecure" | ||
| "google.golang.org/protobuf/types/known/emptypb" | ||
|
|
||
| "github.com/grafana/grafana-plugin-sdk-go/backend/log" | ||
| hermesGrpc "github.com/nasa/hermes/pkg/grpc" | ||
| pb "github.com/nasa/hermes/pkg/pb" | ||
| ) | ||
|
|
||
| type HermesConnection struct { | ||
| hermesClient hermesGrpc.ApiClient | ||
| mu sync.RWMutex | ||
| dictHeads map[string]*pb.DictionaryHead | ||
| dicts map[string]*pb.Dictionary | ||
| } | ||
|
|
||
| func newHermesConn(ctx context.Context, hermesGrpcConnStr string) (*HermesConnection, error) { | ||
| hermesConn, err := grpc.NewClient(hermesGrpcConnStr, grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| h := &HermesConnection{ | ||
| hermesClient: hermesGrpc.NewApiClient(hermesConn), | ||
| dictHeads: make(map[string]*pb.DictionaryHead), | ||
| dicts: make(map[string]*pb.Dictionary), | ||
| } | ||
|
|
||
| if dictList, err := h.hermesClient.AllDictionary(ctx, &emptypb.Empty{}); err != nil { | ||
| return nil, err | ||
| } else { | ||
| h.mu.Lock() | ||
| h.dictHeads = dictList.All | ||
| for dictID := range dictList.GetAll() { | ||
| if _, exists := h.dicts[dictID]; !exists { | ||
| go h.getDict(ctx, dictID) | ||
| } | ||
| } | ||
| h.mu.Unlock() | ||
| } | ||
|
|
||
| go h.syncDicts(ctx) | ||
|
|
||
| return h, nil | ||
| } | ||
|
|
||
| func (h *HermesConnection) syncDicts(ctx context.Context) { | ||
| for { | ||
| select { | ||
| case <-ctx.Done(): | ||
| return | ||
| default: | ||
| dictStream, err := h.hermesClient.SubscribeDictionary(ctx, &emptypb.Empty{}) | ||
| if err != nil { | ||
| log.DefaultLogger.Error("Failed to subscribe to Hermes dictionaries, retrying...", "err", err) | ||
| time.Sleep(5 * time.Second) | ||
| continue | ||
| } | ||
|
|
||
| for { | ||
| dictList, err := dictStream.Recv() | ||
| if err != nil { | ||
| log.DefaultLogger.Error("Hermes dictionary stream error, reconnecting...", "err", err) | ||
| break | ||
| } | ||
|
|
||
| h.mu.Lock() | ||
| h.dictHeads = dictList.All | ||
| for dictId := range h.dictHeads { | ||
| if _, exists := h.dicts[dictId]; !exists { | ||
| go h.getDict(ctx, dictId) | ||
| } | ||
| } | ||
| h.mu.Unlock() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func (h *HermesConnection) getDict(ctx context.Context, dictID string) { | ||
| log.DefaultLogger.Info("Fetching new dictionary", "id", dictID) | ||
|
|
||
| dict, err := h.hermesClient.GetDictionary(ctx, &pb.Id{Id: dictID}) | ||
| if err != nil { | ||
| log.DefaultLogger.Error("Failed to get dictionary definitions", "id", dictID, "err", err) | ||
| return | ||
| } | ||
|
|
||
| h.mu.Lock() | ||
| h.dicts[dictID] = dict | ||
| h.mu.Unlock() | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.