Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandros Filios <[email protected]>
  • Loading branch information
alexandrosfilios committed Jan 16, 2025
1 parent 1a6faf1 commit 39f390f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions platform/view/core/endpoint/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,29 @@ type binder struct {
bindingKVS driver.BindingKVS
}

func (b *binder) Bind(ephemeral, longTerm view.Identity) error {
if ephemeral.IsNone() || longTerm.IsNone() {
func (b *binder) Bind(this, that view.Identity) error {
if this.IsNone() || that.IsNone() {
return errors.New("empty ids passed")
}
// Make sure the long term is passed, so that the hierarchy is flat and all ephemerals point to the long term
longTerm, err := b.bindingKVS.GetBinding(longTerm)
longTerm, err := b.bindingKVS.GetBinding(that)
if err != nil {
return errors.Wrapf(err, "no long term found for [%s]. if long term was passed, it has to be registered first.", longTerm)
return errors.Wrapf(err, "no long term found for [%s]. if long term was passed, it has to be registered first.", that)
}
if longTerm != nil {
return b.bindingKVS.PutBinding(ephemeral, longTerm)
if !longTerm.IsNone() {
logger.Infof("Long term id for [%s] is [%s]", that, longTerm)
return b.bindingKVS.PutBinding(this, longTerm)
}

logger.Infof("Id [%s] has no long term binding. It will be registered as a long-term id.", longTerm)
if err := b.bindingKVS.PutBinding(longTerm, longTerm); err != nil {
return errors.Wrapf(err, "failed to register [%s] as long term", longTerm)
logger.Infof("Id [%s] has no long term binding. It will be registered as a long-term id.", that)
if err := b.bindingKVS.PutBinding(that, that); err != nil {
return errors.Wrapf(err, "failed to register [%s] as long term", that)
}
err = b.bindingKVS.PutBinding(ephemeral, longTerm)
if lt, err := b.bindingKVS.GetBinding(ephemeral); err != nil || lt.IsNone() {
logger.Errorf("wrong binding for [%s][%s]: %v", longTerm, lt, err)
err = b.bindingKVS.PutBinding(this, that)
if lt, err := b.bindingKVS.GetBinding(this); err != nil || lt.IsNone() {
logger.Errorf("wrong binding for [%s][%s]: %v", that, lt, err)
} else {
logger.Errorf("successful binding for [%s]", longTerm)
logger.Errorf("successful binding for [%s]", that)
}
return err
}
Expand Down

0 comments on commit 39f390f

Please sign in to comment.