-
Notifications
You must be signed in to change notification settings - Fork 11
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
Mx 16271 indexing incoming tokens #325
Open
axenteoctavian
wants to merge
15
commits into
feat/sovereign
Choose a base branch
from
MX-16271-indexing-incoming-tokens
base: feat/sovereign
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.
+1,031
−51
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b91174c
Index incoming tokens
axenteoctavian 706e1ff
removed some unused params
axenteoctavian 57b1927
fixes after testing
axenteoctavian b5ebb3f
fixes and improvements after self review
axenteoctavian 9659e73
fixes after self review
axenteoctavian 372b46a
integration test fixes
axenteoctavian a110c90
unit test fixes
axenteoctavian a07073e
integration test fixes
axenteoctavian 646fbbf
script.sh update
axenteoctavian 86bc075
script.sh update
axenteoctavian 73868f5
Merge branch 'feat/sovereign' into MX-16271-indexing-incoming-tokens
axenteoctavian 87cc67f
fixes after review
axenteoctavian 9d96aee
unit test fixes
axenteoctavian d2c8827
fixes after review
axenteoctavian 2bf1792
fixes after review
axenteoctavian 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 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,78 @@ | ||
package disabled | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
) | ||
|
||
type elasticClient struct{} | ||
|
||
// NewDisabledElasticClient - | ||
func NewDisabledElasticClient() *elasticClient { | ||
return &elasticClient{} | ||
} | ||
|
||
// DoBulkRequest - | ||
func (ec *elasticClient) DoBulkRequest(_ context.Context, _ *bytes.Buffer, _ string) error { | ||
return nil | ||
} | ||
|
||
// DoQueryRemove - | ||
func (ec *elasticClient) DoQueryRemove(_ context.Context, _ string, _ *bytes.Buffer) error { | ||
return nil | ||
} | ||
|
||
// DoMultiGet - | ||
func (ec *elasticClient) DoMultiGet(_ context.Context, _ []string, _ string, _ bool, _ interface{}) error { | ||
return nil | ||
} | ||
|
||
// DoScrollRequest - | ||
func (ec *elasticClient) DoScrollRequest(_ context.Context, _ string, _ []byte, _ bool, _ func(responseBytes []byte) error) error { | ||
return nil | ||
} | ||
|
||
// DoCountRequest - | ||
func (ec *elasticClient) DoCountRequest(_ context.Context, _ string, _ []byte) (uint64, error) { | ||
return 0, nil | ||
} | ||
|
||
// UpdateByQuery - | ||
func (ec *elasticClient) UpdateByQuery(_ context.Context, _ string, _ *bytes.Buffer) error { | ||
return nil | ||
} | ||
|
||
// PutMappings - | ||
func (ec *elasticClient) PutMappings(_ string, _ *bytes.Buffer) error { | ||
return nil | ||
} | ||
|
||
// CheckAndCreateIndex - | ||
func (ec *elasticClient) CheckAndCreateIndex(_ string) error { | ||
return nil | ||
} | ||
|
||
// CheckAndCreateAlias - | ||
func (ec *elasticClient) CheckAndCreateAlias(_ string, _ string) error { | ||
return nil | ||
} | ||
|
||
// CheckAndCreateTemplate - | ||
func (ec *elasticClient) CheckAndCreateTemplate(_ string, _ *bytes.Buffer) error { | ||
return nil | ||
} | ||
|
||
// CheckAndCreatePolicy - | ||
func (ec *elasticClient) CheckAndCreatePolicy(_ string, _ *bytes.Buffer) error { | ||
return nil | ||
} | ||
|
||
// IsEnabled - | ||
func (ec *elasticClient) IsEnabled() bool { | ||
return false | ||
} | ||
|
||
// IsInterfaceNil - returns true if there is no value under the interface | ||
func (ec *elasticClient) IsInterfaceNil() bool { | ||
return ec == nil | ||
} |
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,31 @@ | ||
package disabled | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDisabledElasticClient_MethodsShouldNotPanic(t *testing.T) { | ||
t.Parallel() | ||
|
||
ec := NewDisabledElasticClient() | ||
require.False(t, check.IfNil(ec)) | ||
|
||
require.NotPanics(t, func() { | ||
_ = ec.DoBulkRequest(context.Background(), new(bytes.Buffer), "") | ||
_ = ec.DoQueryRemove(context.Background(), "", new(bytes.Buffer)) | ||
_ = ec.DoMultiGet(context.Background(), make([]string, 0), "", true, nil) | ||
_ = ec.DoScrollRequest(context.Background(), "", []byte(""), true, nil) | ||
_, _ = ec.DoCountRequest(context.Background(), "", []byte("")) | ||
_ = ec.UpdateByQuery(context.Background(), "", new(bytes.Buffer)) | ||
_ = ec.PutMappings("", new(bytes.Buffer)) | ||
_ = ec.CheckAndCreateIndex("") | ||
_ = ec.CheckAndCreateAlias("", "") | ||
_ = ec.CheckAndCreateTemplate("", new(bytes.Buffer)) | ||
_ = ec.CheckAndCreatePolicy("", new(bytes.Buffer)) | ||
}) | ||
} |
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,28 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/elastic/go-elasticsearch/v7" | ||
) | ||
|
||
type mainChainElasticClient struct { | ||
*elasticClient | ||
indexingEnabled bool | ||
} | ||
|
||
// NewMainChainElasticClient creates a new sovereign elastic client | ||
func NewMainChainElasticClient(cfg elasticsearch.Config, indexingEnabled bool) (*mainChainElasticClient, error) { | ||
esClient, err := NewElasticClient(cfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &mainChainElasticClient{ | ||
esClient, | ||
indexingEnabled, | ||
}, nil | ||
} | ||
|
||
// IsEnabled returns true if main chain elastic client is enabled | ||
func (mcec *mainChainElasticClient) IsEnabled() bool { | ||
return mcec.indexingEnabled | ||
} |
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,36 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/elastic/go-elasticsearch/v7" | ||
"github.com/stretchr/testify/require" | ||
|
||
indexer "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" | ||
) | ||
|
||
func TestNewMainChainElasticClient(t *testing.T) { | ||
t.Run("no url, should error", func(t *testing.T) { | ||
esClient, err := NewMainChainElasticClient(elasticsearch.Config{ | ||
Addresses: []string{}, | ||
}, true) | ||
require.Nil(t, esClient) | ||
require.Equal(t, indexer.ErrNoElasticUrlProvided, err) | ||
}) | ||
t.Run("should work", func(t *testing.T) { | ||
esClient, err := NewMainChainElasticClient(elasticsearch.Config{ | ||
Addresses: []string{"http://localhost:9200"}, | ||
}, true) | ||
require.Nil(t, err) | ||
require.Equal(t, "*client.mainChainElasticClient", fmt.Sprintf("%T", esClient)) | ||
}) | ||
} | ||
|
||
func TestMainChainElasticClient_IsEnabled(t *testing.T) { | ||
esClient, err := NewMainChainElasticClient(elasticsearch.Config{ | ||
Addresses: []string{"http://localhost:9200"}, | ||
}, true) | ||
require.Nil(t, err) | ||
require.Equal(t, true, esClient.IsEnabled()) | ||
} |
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 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 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
|
||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
|
||
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc" | ||
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions" | ||
) | ||
|
||
|
@@ -34,7 +35,10 @@ func NewManagedRunTypeComponents(rtc RunTypeComponentsCreator) (*managedRunTypeC | |
|
||
// Create will create the managed components | ||
func (mrtc *managedRunTypeComponents) Create() error { | ||
rtc := mrtc.factory.Create() | ||
rtc, err := mrtc.factory.Create() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
mrtc.mutRunTypeCoreComponents.Lock() | ||
mrtc.runTypeComponents = rtc | ||
|
@@ -75,6 +79,9 @@ func (mrtc *managedRunTypeComponents) CheckSubcomponents() error { | |
if check.IfNil(mrtc.rewardTxData) { | ||
return transactions.ErrNilRewardTxDataHandler | ||
} | ||
if check.IfNil(mrtc.indexTokensHandler) { | ||
return transactions.ErrNilIndexTokensHandler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe you should move |
||
} | ||
return nil | ||
} | ||
|
||
|
@@ -102,6 +109,18 @@ func (mrtc *managedRunTypeComponents) RewardTxDataCreator() transactions.RewardT | |
return mrtc.runTypeComponents.rewardTxData | ||
} | ||
|
||
// IndexTokensHandlerCreator returns the index tokens handler | ||
func (mrtc *managedRunTypeComponents) IndexTokensHandlerCreator() elasticproc.IndexTokensHandler { | ||
mrtc.mutRunTypeCoreComponents.Lock() | ||
defer mrtc.mutRunTypeCoreComponents.Unlock() | ||
|
||
if check.IfNil(mrtc.runTypeComponents) { | ||
return nil | ||
} | ||
|
||
return mrtc.runTypeComponents.indexTokensHandler | ||
} | ||
|
||
// IsInterfaceNil returns true if the interface is nil | ||
func (mrtc *managedRunTypeComponents) IsInterfaceNil() bool { | ||
return mrtc == nil | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can add a comment here to describe for what is used this section of config