<commit_before>// Copyright (c) 2017 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package msgsync

import (
	"errors"

	"github.com/golang/protobuf/proto"
	"github.com/ligato/cn-infra/datasync"
	"github.com/ligato/cn-infra/flavors/local"
	"github.com/ligato/cn-infra/messaging"
)

// PubPlugin implements KeyProtoValWriter that propagates protobuf messages
// to a particular topic (unless the messaging.Mux is not disabled).
type PubPlugin struct {
	Deps    // inject
	adapter messaging.ProtoPublisher
}

// Deps groups dependencies injected into the plugin so that they are
// logically separated from other plugin fields.
type Deps struct {
	local.PluginInfraDeps               // inject
	Messaging             messaging.Mux // inject
	Cfg
}

// Deps groups configurations fields. It can be extended with other fields
// (such as sync/async, partition...)
type Cfg struct {
	Topic string
}

// Init does nothing
func (plugin *PubPlugin) Init() error {
	return nil
}

// AfterInit uses provided MUX connection to build new publisher.
func (plugin *PubPlugin) AfterInit() error {
	if !plugin.Messaging.Disabled() {
		cfg := plugin.Deps.Cfg
		plugin.PluginConfig.GetValue(&cfg)

		if cfg.Topic != "" {
			var err error
			plugin.adapter, err = plugin.Messaging.NewSyncPublisher("msgsync-connection", cfg.Topic)
			if err != nil {
				return err<commit_msg>Update plugin_impl_msgsync.go<commit_after>// Copyright (c) 2017 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package msgsync

import (
	"errors"

	"github.com/golang/protobuf/proto"
	"github.com/ligato/cn-infra/datasync"
	"github.com/ligato/cn-infra/flavors/local"
	"github.com/ligato/cn-infra/messaging"
)

// PubPlugin implements KeyProtoValWriter that propagates protobuf messages
// to a particular topic (unless the messaging.Mux is not disabled).
type PubPlugin struct {
	Deps    // inject
	adapter messaging.ProtoPublisher
}

// Deps groups dependencies injected into the plugin so that they are
// logically separated from other plugin fields.
type Deps struct {
	local.PluginInfraDeps               // inject
	Messaging             messaging.Mux // inject
	Cfg
}

// Cfg groups configurations fields. It can be extended with other fields
// (such as sync/async, partition...)
type Cfg struct {
	Topic string
}

// Init does nothing
func (plugin *PubPlugin) Init() error {
	return nil
}

// AfterInit uses provided MUX connection to build new publisher.
func (plugin *PubPlugin) AfterInit() error {
	if !plugin.Messaging.Disabled() {
		cfg := plugin.Deps.Cfg
		plugin.PluginConfig.GetValue(&cfg)

		if cfg.Topic != "" {
			var err error
			plugin.adapter, err = plugin.Messaging.NewSyncPublisher("msgsync-connection", cfg.Topic)
			if err != nil {
				return err
{'fraction_non_alphanumeric': 0.09672346002621232, 'fraction_numerical': 0.0041939711664482305, 'mean_word_length': 3.442374854481956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4655055', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1062, 'n_words': 414}