<commit_before>package acl

import (
	"github.com/ligato/cn-infra/logging"
	"github.com/ligato/vpp-agent/clientv1/linux"

	"github.com/contiv/vpp/plugins/policy/renderer"
	"github.com/contiv/vpp/plugins/policy/renderer/cache"
)

// Renderer renders Contiv Rules into VPP ACLs.
// ACLs are installed into VPP by the aclplugin from vpp-agent.
// The configuration changes are transported into aclplugin via localclient.
type Renderer struct {
	Deps

	aclTxnFactory func() (dsl linux.DataChangeDSL)
	aclResyncTxnFactory func() (dsl linux.DataResyncDSL)
}

// Deps lists dependencies of Renderer.
type Deps struct {
	Log   logging.Logger
	Cache cache.ContivRuleCacheAPI
}

// RendererTxn represents a single transaction of Renderer.
type RendererTxn struct {
	cacheTxn cache.Txn
	resync   bool
}

func NewRenderer(
	aclTxnFactory func() (dsl linux.DataChangeDSL),
	aclResyncTxnFactory func() (dsl linux.DataResyncDSL),
) *Renderer {
	return &Renderer{aclTxnFactory: aclTxnFactory, aclResyncTxnFactory: aclResyncTxnFactory}
}

// NewTxn starts a new transaction. The rendering executes only after Commit()
// is called. Rollback is not yet supported however.
// If <resync> is enabled, the supplied configuration will completely
// replace the existing one. Otherwise, the change is performed incrementally,
// i.e. interfaces not mentioned in the transaction are left unaffected.
func (ar *Renderer) NewTxn(resync bool) *RendererTxn {
	return &RendererTxn{cacheTxn: ar.Cache.NewTxn(resync), resync: resync}
}

// Render applies the set of ingress & egress rules for a given VPP interface.
// The existing rules are replaced.
// Te actual change is performed only after the commit.
func (art *RendererTxn) Render(ifName string, ingress []renderer.ContivRule, egress []renderer.ContivRule) *RendererTxn {
	art.cacheTxn.Update(ifName, ingress, egress)
	return art<commit_msg>Fix golint and gofmt issues.<commit_after>package acl

import (
	"github.com/ligato/cn-infra/logging"
	"github.com/ligato/vpp-agent/clientv1/linux"

	"github.com/contiv/vpp/plugins/policy/renderer"
	"github.com/contiv/vpp/plugins/policy/renderer/cache"
)

// Renderer renders Contiv Rules into VPP ACLs.
// ACLs are installed into VPP by the aclplugin from vpp-agent.
// The configuration changes are transported into aclplugin via localclient.
type Renderer struct {
	Deps

	aclTxnFactory       func() (dsl linux.DataChangeDSL)
	aclResyncTxnFactory func() (dsl linux.DataResyncDSL)
}

// Deps lists dependencies of Renderer.
type Deps struct {
	Log   logging.Logger
	Cache cache.ContivRuleCacheAPI
}

// RendererTxn represents a single transaction of Renderer.
type RendererTxn struct {
	cacheTxn cache.Txn
	resync   bool
}

// NewRenderer is a constructor for ACL Renderer.
func NewRenderer(
	aclTxnFactory func() (dsl linux.DataChangeDSL),
	aclResyncTxnFactory func() (dsl linux.DataResyncDSL),
) *Renderer {
	return &Renderer{aclTxnFactory: aclTxnFactory, aclResyncTxnFactory: aclResyncTxnFactory}
}

// NewTxn starts a new transaction. The rendering executes only after Commit()
// is called. Rollback is not yet supported however.
// If <resync> is enabled, the supplied configuration will completely
// replace the existing one. Otherwise, the change is performed incrementally,
// i.e. interfaces not mentioned in the transaction are left unaffected.
func (ar *Renderer) NewTxn(resync bool) *RendererTxn {
	return &RendererTxn{cacheTxn: ar.Cache.NewTxn(resync), resync: resync}
}

// Render applies the set of ingress & egress rules for a given VPP interface.
// The existing rules are replaced.
// Te actual change is performed only after the commit.
func (art *RendererTxn) Render(ifName string, ingress []renderer.ContivRule, egress []renderer.ContivRule) *RendererTxn {
	art.cacheTxn.Update(ifName, ingress, egress)
	return art
{'fraction_non_alphanumeric': 0.08930916732335172, 'fraction_numerical': 0.0005253480430785396, 'mean_word_length': 4.6751117734724295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6428801', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1205, 'n_words': 386}