Skip to content

Commit

Permalink
object: Purge notification functionality
Browse files Browse the repository at this point in the history
It was removed from the protocol within
nspcc-dev/neofs-api#279.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Feb 26, 2024
1 parent 9756cc4 commit 982b2c9
Show file tree
Hide file tree
Showing 19 changed files with 8 additions and 722 deletions.
4 changes: 0 additions & 4 deletions .github/testcases-env
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ IR_IMAGE=nspccdev/neofs-ir
NODE_VERSION=_TAG_
NODE_IMAGE=nspccdev/neofs-storage

# NATS Server
NATS_VERSION=2.7.2
NATS_IMAGE=nats

# HTTP Gate
HTTP_GW_VERSION=0.28.0
HTTP_GW_IMAGE=nspccdev/neofs-http-gw
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog for NeoFS Node
### Changed

### Removed
- Object notifications incl. NATS (#xxx))

### Updated

Expand Down
47 changes: 1 addition & 46 deletions cmd/neofs-cli/modules/object/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import (
)

const (
noProgressFlag = "no-progress"
notificationFlag = "notify"
noProgressFlag = "no-progress"
)

var putExpiredOn uint64
Expand Down Expand Up @@ -55,7 +54,6 @@ func initObjectPutCmd() {
flags.Uint64P(commonflags.Lifetime, "l", 0, "Number of epochs for object to stay valid")
flags.Bool(noProgressFlag, false, "Do not show progress bar")

flags.String(notificationFlag, "", "Object notification in the form of *epoch*:*topic*; '-' topic means using default")
flags.Bool(binaryFlag, false, "Deserialize object structure from given file.")
objectPutCmd.MarkFlagsMutuallyExclusive(commonflags.ExpireAt, commonflags.Lifetime)
}
Expand Down Expand Up @@ -139,13 +137,6 @@ func putObject(cmd *cobra.Command, _ []string) {
obj.SetOwnerID(&ownerID)
obj.SetAttributes(attrs...)

notificationInfo, err := parseObjectNotifications(cmd)
common.ExitOnErr(cmd, "can't parse object notification information: %w", err)

if notificationInfo != nil {
obj.SetNotification(*notificationInfo)
}

var prm internalclient.PutObjectPrm
prm.SetPrivateKey(*pk)
ReadOrOpenSession(ctx, cmd, &prm, pk, cnr, nil)
Expand Down Expand Up @@ -224,39 +215,3 @@ func parseObjectAttrs(cmd *cobra.Command) ([]object.Attribute, error) {

return attrs, nil
}

func parseObjectNotifications(cmd *cobra.Command) (*object.NotificationInfo, error) {
const (
separator = ":"
useDefaultTopic = "-"
)

raw := cmd.Flag(notificationFlag).Value.String()
if raw == "" {
return nil, nil
}

rawSlice := strings.SplitN(raw, separator, 2)
if len(rawSlice) != 2 {
return nil, fmt.Errorf("notification must be in the form of: *epoch*%s*topic*, got %s", separator, raw)
}

ni := new(object.NotificationInfo)

epoch, err := strconv.ParseUint(rawSlice[0], 10, 64)
if err != nil {
return nil, fmt.Errorf("could not parse notification epoch %s: %w", rawSlice[0], err)
}

ni.SetEpoch(epoch)

if rawSlice[1] == "" {
return nil, fmt.Errorf("incorrect empty topic: use %s to force using default topic", useDefaultTopic)
}

if rawSlice[1] != useDefaultTopic {
ni.SetTopic(rawSlice[1])
}

return ni, nil
}
7 changes: 0 additions & 7 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ type cfg struct {
cfgControlService cfgControlService
cfgReputation cfgReputation
cfgObject cfgObject
cfgNotifications cfgNotifications
}

// ReadCurrentNetMap reads network map which has been cached at the
Expand Down Expand Up @@ -475,12 +474,6 @@ type cfgObject struct {
tombstoneLifetime uint64
}

type cfgNotifications struct {
enabled bool
nw notificationWriter
defaultTopic string
}

type cfgLocalStorage struct {
localStorage *engine.StorageEngine
}
Expand Down
76 changes: 0 additions & 76 deletions cmd/neofs-node/config/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ type PersistentStateConfig struct {
cfg *config.Config
}

// NotificationConfig is a wrapper over "notification" config section
// which provides access to object notification configuration of node.
type NotificationConfig struct {
cfg *config.Config
}

const (
subsection = "node"
persistentSessionsSubsection = "persistent_sessions"
persistentStateSubsection = "persistent_state"
notificationSubsection = "notification"

attributePrefix = "attribute"

Expand Down Expand Up @@ -176,72 +169,3 @@ func (p PersistentStateConfig) Path() string {

return PersistentStatePathDefault
}

// Notification returns structure that provides access to "notification"
// subsection of "node" section.
func Notification(c *config.Config) NotificationConfig {
return NotificationConfig{
c.Sub(subsection).Sub(notificationSubsection),
}
}

// Enabled returns the value of "enabled" config parameter from "notification"
// subsection of "node" section.
//
// Returns false if the value is not presented.
func (n NotificationConfig) Enabled() bool {
return config.BoolSafe(n.cfg, "enabled")
}

// DefaultTopic returns the value of "default_topic" config parameter from
// "notification" subsection of "node" section.
//
// Returns empty string if the value is not presented.
func (n NotificationConfig) DefaultTopic() string {
return config.StringSafe(n.cfg, "default_topic")
}

// Endpoint returns the value of "endpoint" config parameter from "notification"
// subsection of "node" section.
//
// Returns empty string if the value is not presented.
func (n NotificationConfig) Endpoint() string {
return config.StringSafe(n.cfg, "endpoint")
}

// Timeout returns the value of "timeout" config parameter from "notification"
// subsection of "node" section.
//
// Returns NotificationTimeoutDefault if the value is not positive.
func (n NotificationConfig) Timeout() time.Duration {
v := config.DurationSafe(n.cfg, "timeout")
if v > 0 {
return v
}

return NotificationTimeoutDefault
}

// CertPath returns the value of "certificate_path" config parameter from "notification"
// subsection of "node" section.
//
// Returns empty string if the value is not presented.
func (n NotificationConfig) CertPath() string {
return config.StringSafe(n.cfg, "certificate")
}

// KeyPath returns the value of "key_path" config parameter from
// "notification" subsection of "node" section.
//
// Returns empty string if the value is not presented.
func (n NotificationConfig) KeyPath() string {
return config.StringSafe(n.cfg, "key")
}

// CAPath returns the value of "ca_path" config parameter from
// "notification" subsection of "node" section.
//
// Returns empty string if the value is not presented.
func (n NotificationConfig) CAPath() string {
return config.StringSafe(n.cfg, "ca")
}
29 changes: 0 additions & 29 deletions cmd/neofs-node/config/node/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nodeconfig

import (
"testing"
"time"

"github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
Expand Down Expand Up @@ -33,25 +32,11 @@ func TestNodeSection(t *testing.T) {
relay := Relay(empty)
persisessionsPath := PersistentSessions(empty).Path()
persistatePath := PersistentState(empty).Path()
notificationDefaultEnabled := Notification(empty).Enabled()
notificationDefaultEndpoint := Notification(empty).Endpoint()
notificationDefaultTimeout := Notification(empty).Timeout()
notificationDefaultTopic := Notification(empty).DefaultTopic()
notificationDefaultCertPath := Notification(empty).CertPath()
notificationDefaultKeyPath := Notification(empty).KeyPath()
notificationDefaultCAPath := Notification(empty).CAPath()

require.Empty(t, attribute)
require.Equal(t, false, relay)
require.Equal(t, "", persisessionsPath)
require.Equal(t, PersistentStatePathDefault, persistatePath)
require.Equal(t, false, notificationDefaultEnabled)
require.Equal(t, "", notificationDefaultEndpoint)
require.Equal(t, NotificationTimeoutDefault, notificationDefaultTimeout)
require.Equal(t, "", notificationDefaultTopic)
require.Equal(t, "", notificationDefaultCertPath)
require.Equal(t, "", notificationDefaultKeyPath)
require.Equal(t, "", notificationDefaultCAPath)
})

const path = "../../../../config/example/node"
Expand All @@ -64,13 +49,6 @@ func TestNodeSection(t *testing.T) {
wKey := Wallet(c)
persisessionsPath := PersistentSessions(c).Path()
persistatePath := PersistentState(c).Path()
notificationEnabled := Notification(c).Enabled()
notificationEndpoint := Notification(c).Endpoint()
notificationTimeout := Notification(c).Timeout()
notificationDefaultTopic := Notification(c).DefaultTopic()
notificationCertPath := Notification(c).CertPath()
notificationKeyPath := Notification(c).KeyPath()
notificationCAPath := Notification(c).CAPath()

expectedAddr := []struct {
str string
Expand Down Expand Up @@ -123,13 +101,6 @@ func TestNodeSection(t *testing.T) {

require.Equal(t, "/sessions", persisessionsPath)
require.Equal(t, "/state", persistatePath)
require.Equal(t, true, notificationEnabled)
require.Equal(t, "tls://localhost:4222", notificationEndpoint)
require.Equal(t, 6*time.Second, notificationTimeout)
require.Equal(t, "topic", notificationDefaultTopic)
require.Equal(t, "/cert/path", notificationCertPath)
require.Equal(t, "/key/path", notificationKeyPath)
require.Equal(t, "/ca/path", notificationCAPath)
}

configtest.ForEachFileType(path, fileConfigTest)
Expand Down
2 changes: 0 additions & 2 deletions cmd/neofs-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func initApp(c *cfg) {
initAndLog(c, "accounting", initAccountingService)
initAndLog(c, "session", initSessionService)
initAndLog(c, "reputation", initReputationService)
initAndLog(c, "notification", initNotifications)
initAndLog(c, "object", initObjectService)
initAndLog(c, "tree", initTreeService)

Expand Down Expand Up @@ -165,7 +164,6 @@ func runAndLog(c *cfg, name string, logSuccess bool, starter func(*cfg)) {
}

func bootUp(c *cfg) {
runAndLog(c, "NATS", true, connectNats)
runAndLog(c, "gRPC", false, serveGRPC)
runAndLog(c, "notary", true, makeAndWaitNotaryDeposit)

Expand Down
Loading

0 comments on commit 982b2c9

Please sign in to comment.